When doing a search I want to skip all code that ends in a closing tag
I have HTML that looks like this:
<td class="danish"> Det tycker jag!</td>
I'm fixing the line break with this:
<td class="danish">(.*) \s*(.*)</td>
But sometimes the HTML ends in a tag on the same line:
<td class="danish">Det tyckeg jag</td>
I want it to skip lines like these when searching and find the next broken line.
In case anyone thinks it's just a frivolous thing to make the code look good, the rest of the code looks like this (not required reading):
<td class="danish"> Det tycker jag!</td> <td> <?php audioButton("../../audio//det_lyder_godt","det_lyder_godt"); ?>
I ultimately have to take the text in the table and replace the one in the audiobutton a thousand times, but that's a different problemАвтор: Moogal Источник Размещён: 08.11.2019 11:22
I think this is what you're looking for:
This matches from
<td class="danish"> to the next newline, unless there's a
</td> tag first. Replace with
"$1 " or
"\1 " (without the quotes).
\r?\n instead of a literal newline makes the regex more robust. Even better is
\R, if your regex flavor supports it.
\s means "any white-space character", which includes spaces and new lines. You could explicitly search for lines that must contain a new line, by using something like:
Note the additional
\n in the regex.