Question

hi i'm having this html markup

<body>
<table border="0" width="50%" align="center">
<tr>
<td>




<center>

and i'm trying to find a "wildcard" for the linebreaks to reach the <center> tag - how would this work?

thx

Was it helpful?

Solution

The normal RegEx to find a repeating linebreak is "[\r\n]+" which means at least 1 linebreak. This will match any number of linebreaks following directly after each other.

OTHER TIPS

/(\s*\n){2,}/

Since some platforms use \r\n as their line-break, and some use only \n this will search for successive strings of whitespace (which \r should also be considered) followed by \n, and ensure to match 2 of them.

Firebug console test:

>>> /(\s*\n){2,}/.exec("<tr>\r\n<td> \r\n \t \r\n \n\n<center>");
[" \r\n \r\n \n\n", "\n"]
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top