User:ArrowHead294/Regex snippets

From Xenharmonic Wiki
Jump to navigation Jump to search

These are some regular expressions I use for formatting purposes:

Pattern Replace by Purpose
^(?:\+|-|\x{2212})?(?:(?:\d{1,3}?(?:\,\d{3})*|\d+)\.?\d*|\d*\.?\d+)(?:[Ee][+-]?\d+)?$ N/A Match a number
(?<!(<nowiki>[^\n]*)|\{|\})(?<=\n)\|\s*(?!-|<\/nowiki>|\{|\}) Space out pipe characters in tables (one cell per line)*

* Won't work if variable-length lookaheads and lookbehinds aren't supported