Difference between revisions of "User:Megavolt/regex"

From Manjaro
Jump to navigation Jump to search
m (correction)
m (update)
 
Line 6: Line 6:
 
{| class="wikitable sortable"
 
{| class="wikitable sortable"
 
|-
 
|-
! description !! Search !! Replace
+
! Description !! Search !! Replace
 
|-
 
|-
| rowspan="2"|Add "Special:MyLanguage" to internal links
+
| rowspan="2" | Add "Special:MyLanguage" to internal links
| <nowiki>(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 '+-_#]+)\]\]</nowiki>
+
| <nowiki>(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 ()'+-_#]+)\]\]</nowiki>
 
| <nowiki>[[Special:MyLanguage/$5|&lt;translate>$5&lt;/translate>]]</nowiki>
 
| <nowiki>[[Special:MyLanguage/$5|&lt;translate>$5&lt;/translate>]]</nowiki>
 
|-
 
|-
| <nowiki>(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 '+-_#]+)\|([A-Za-z0-9 '+-_#]+)\]\]</nowiki>
+
| <nowiki>(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 ()'+-_#]+)\|([A-Za-z0-9 ()'+-_#]+)\]\]</nowiki>
 
| <nowiki>[[Special:MyLanguage/$5|&lt;translate>$6&lt;/translate>]]</nowiki>
 
| <nowiki>[[Special:MyLanguage/$5|&lt;translate>$6&lt;/translate>]]</nowiki>
 +
|
 +
|-
 +
| rowspan="4" | links within &lt;translate> tags
 +
| <nowiki>\[(http(s|):\/\/[A-Za-z./-_]+) ([A-Za-z0-9 ()'+-_#]+)\]</nowiki>
 +
| <nowiki>[&lt;tvar|link>$1&lt;/> $3]</nowiki>
 +
|-
 +
| <nowiki>\[(http(s|):\/\/[A-Za-z./-_]+)]</nowiki>
 +
| <nowiki>[&lt;tvar|link>$1&lt;/>]</nowiki>
 +
|-
 +
| <nowiki>(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 ()'+-_#]+)\|([A-Za-z0-9 ()'+-_#]+)\]\]</nowiki>
 +
| <nowiki>[[&lt;tvar|link>Special:MyLanguage/$5</>|$6]]</nowiki>
 +
|-
 +
| <nowiki>(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 ()'+-_#]+)\]\]</nowiki>
 +
| <nowiki>[[&lt;tvar|link>Special:MyLanguage/$5</>|$5]]</nowiki>
 
|-
 
|-
 
| Remove misc tags of the translate extension
 
| Remove misc tags of the translate extension
Line 20: Line 34:
 
|-
 
|-
 
| rowspan="3" | prepare categories
 
| rowspan="3" | prepare categories
| <nowiki>\[\[((C|c)ategory:([A-Za-z0-9 '+-_#]+))\]\]</nowiki>
+
| <nowiki>\[\[((C|c)ategory:([A-Za-z0-9 ()'+-_#]+))\]\]</nowiki>
 
| <nowiki>[[$1{{#translation:}}]]</nowiki>
 
| <nowiki>[[$1{{#translation:}}]]</nowiki>
 
|-
 
|-
| <nowiki>\[\[(:(C|c)ategory:([A-Za-z0-9 '+-_#]+))\]\]</nowiki>
+
| <nowiki>\[\[(:(C|c)ategory:([A-Za-z0-9 ()'+-_#]+))\]\]</nowiki>
 
| <nowiki>[[$3{{#translation:}}|&lt;translate>$3&lt;/translate>]]</nowiki>
 
| <nowiki>[[$3{{#translation:}}|&lt;translate>$3&lt;/translate>]]</nowiki>
 
|-
 
|-
| <nowiki>\[\[(:(C|c)ategory:([A-Za-z0-9 '+-_#]+)\|([A-Za-z0-9 '+-_#]+))\]\]</nowiki>
+
| <nowiki>\[\[(:(C|c)ategory:([A-Za-z0-9 ()'+-_#]+)\|([A-Za-z0-9 ()'+-_#]+))\]\]</nowiki>
 
| <nowiki>[[$3{{#translation:}}|&lt;translate>$4&lt;/translate>]]</nowiki>
 
| <nowiki>[[$3{{#translation:}}|&lt;translate>$4&lt;/translate>]]</nowiki>
 
|-
 
|-
 
| prepare lists
 
| prepare lists
| <nowiki>(?!(\* |\*  )(''|''')(\[\[|\[)|(\* |\*  )<translate>)(\* |\*  )([A-Za-z0-9 '+-_#,.()]+)</nowiki>
+
| <nowiki>(?!(\* |\*  )(''|''')(\[\[|\[)|(\* |\*  )<translate>)(\* |\*  )([A-Za-z0-9 ()'+-_#,.()]+)</nowiki>
| <nowiki>* <translate>$4</translate></nowiki>
+
| <nowiki>* &lt;translate>$4&lt;/translate></nowiki>
 
|}
 
|}

Latest revision as of 10:00, 31 March 2021


Here i will add a list of regex commands for daily usage for remembering.

Description Search Replace
Add "Special:MyLanguage" to internal links (?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 ()'+-_#]+)\]\] [[Special:MyLanguage/$5|<translate>$5</translate>]]
(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 ()'+-_#]+)\|([A-Za-z0-9 ()'+-_#]+)\]\] [[Special:MyLanguage/$5|<translate>$6</translate>]]
links within <translate> tags \[(http(s|):\/\/[A-Za-z./-_]+) ([A-Za-z0-9 ()'+-_#]+)\] [<tvar|link>$1</> $3]
\[(http(s|):\/\/[A-Za-z./-_]+)] [<tvar|link>$1</>]
(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 ()'+-_#]+)\|([A-Za-z0-9 ()'+-_#]+)\]\] [[<tvar|link>Special:MyLanguage/$5</>|$6]]
(?!\[\[(C|c)ategory:|\[\[(F|f)ile:|\[\[(I|i)mage:|\[\[(S|s)pecial:MyLanguage/)\[\[([A-Za-z0-9 ()'+-_#]+)\]\] [[<tvar|link>Special:MyLanguage/$5</>|$5]]
Remove misc tags of the translate extension <!--T:\d+-->
<(/|)translate>
prepare categories \[\[((C|c)ategory:([A-Za-z0-9 ()'+-_#]+))\]\] [[$1{{#translation:}}]]
\[\[(:(C|c)ategory:([A-Za-z0-9 ()'+-_#]+))\]\] [[$3{{#translation:}}|<translate>$3</translate>]]
\[\[(:(C|c)ategory:([A-Za-z0-9 ()'+-_#]+)\|([A-Za-z0-9 ()'+-_#]+))\]\] [[$3{{#translation:}}|<translate>$4</translate>]]
prepare lists (?!(\* |\* )(''|''')(\[\[|\[)|(\* |\* )<translate>)(\* |\* )([A-Za-z0-9 ()'+-_#,.()]+) * <translate>$4</translate>