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
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
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.
/(\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"]