Topic on Extension talk:Regex Fun

213.30.140.219 (talkcontribs)

How can you specify alternation (|) in the pattern for #regex? e.g. if you want to match {{ #regex: abcdef | /abc|def/ }} ? Alternatives such as calling #regex twice won't work for me.

Danwe (talkcontribs)

Two possible ways:

  • Define a Template:! in your wiki which contains nothing move than a |. Then use {{ #regex: abcdef | /abc{{!}}def/ }}.
  • Use the regex ascii escaping syntax. Without looking it up, \x7C should work if I am not misstaken. {{ #regex: abcdef | /abc\x7Cdef/ }}.
Reply to "Alternation"