I'm making a plugin that will create a table based on some pre-existing data.
Sometimes, some of that data has line breaks (\n or \r) in the middle, and that is out of my control. After I finish parsing the data, the software will replace all line breaks with <br>
, so I need to remove all of them that are not inside <th>
or <td>
This regex will match all of them (Fiddle):
(>[^<]*)\n([^<]*<)
How can I make it match all line breaks, except the ones inside <td></td>
and <th></th>
Thank you
automatically. My problem are the line breaks NOT inside