eric_han

Wikipedia Regular Expressions

Jan 10th, 2023 (edited)
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. Line Breaks
  2.  
  3. SEARCH
  4. for legal and illegal forms of HTML Line Break Tag. Open tag, closing tag, self-closing tag. Allow whitespace before and after 'br' Tag ID. Allow whitespace before opening Tag Delimiter (<) and after closing Tag Delimiter (>).
  5.  
  6. Wikimedia Tag Parser has funny rules for an HTML Line Break Tag. No matching Begin/End tags (<br></br>). Either Begin or End tag alone counts as a Line Break Tag. After normal start to tag (<br or </br), almost anything goes until closing '>'. Including a text Line Break!
  7.  
  8. \s*<\/?br(\s*[^|{}]*)?>\s*
  9.  
  10. REPLACE
  11. HTML Line Break Tag with Wikimedia {{break}} template. Replacement string includes a space before opening Template Delimiter ({{) and after closing Template Delimiter (}}).
  12.  
  13. {{break | 1}}
  14.  
  15. ยง
  16.  
  17. Spacing for Pipe Bars (|) in Templates
  18.  
  19. SEARCH
  20. for Pipe Bars (|), possibly preceded or followed by whitespace. Do not accept a newline character (NL) as whitespace. In practice, accept non-NL whitespace preceding or following a Pipe Bar. In aspiration, reject any string of whitespace that has an NL in it. But it was a lot of work to get the search expression to work as well as it does. Improving the search expression is a task for somewhere between later and never.
  21.  
  22. REPLACE
  23. existent or nonexistent whitespace with nice whitespace
Advertisement
Add Comment
Please, Sign In to add comment