Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
regex [2021/03/18 20:06] – created niklasregex [2021/03/19 08:57] niklas
Line 1: Line 1:
-remove extra attributes to p:+====== Useful regular expressions ====== 
 + 
 +=====Clean paragraph tags===== 
 +Replace
 <code><p[^>]+></code> <code><p[^>]+></code>
-remove span tags:+with  
 +<code><p></code> 
 +=====remove span tags:===== 
 +Replace
 <code><[/]?span[^>]*></code> <code><[/]?span[^>]*></code>
-**To h4:**+with nothing 
 + 
 +=====Remove empty paragraph tags:===== 
 +Replace 
 +<code><p[^>]*>&nbsp;</p></code> 
 +with nothing 
 + 
 +Replace 
 +<code><p[^>]*>[ ]?</p></code> 
 +with nothing 
 + 
 +=====Bold paragraphs to h4:===== 
 +Replace
 <code> <code>
 <p[^>]*><strong>([^<]+)</strong></p> <p[^>]*><strong>([^<]+)</strong></p>
 <p[^>]*><b>([^<]+)</b></p></code> <p[^>]*><b>([^<]+)</b></p></code>
-Replace with:+With:
 <code> <code>
 <h4>\1</h4> <h4>\1</h4>
 </code> </code>
-**Remove empty p tags:** +=====Handling footnotes:=====
-<code><p[^>]*>&nbsp;</p></code> +
-**Handling footnotes:**+
 <code> <code>
 <a (href="#_ftn[0-9]") (name="_ftnref[0-9]") title=""></a>(\[[0-9]\]) <a (href="#_ftn[0-9]") (name="_ftnref[0-9]") title=""></a>(\[[0-9]\])
Line 34: Line 50:
 \1<sup><a name="_ftnref\2" /><a href="#_ftn\2">\2</a></sup>\3 \1<sup><a name="_ftnref\2" /><a href="#_ftn\2">\2</a></sup>\3
 </code> </code>
-**Finding and replacing double quotation:**+=====Finding and replacing double quotation:=====
 <code> <code>
 (?<!\=)"((?!"|'')[^"\n>]*)("|'')(?!>)(\W) (?<!\=)"((?!"|'')[^"\n>]*)("|'')(?!>)(\W)
Line 44: Line 60:
  
 <code>‘\1’\3</code> <code>‘\1’\3</code>
 +
 +=====Removing line breaks in code:=====
 +This is useful if above isn't working because of line breaks.
 +Replace 
 +<code>\n</p> </code>
 +with 
 +<code></p></code>
 +Replace
 + <code>\r\n</p></code>
 +with 
 +<code></p></code>