Here is a regular expression that does the tric:
(?:^.*(the text that should be kept).*$)|^.*\r?\n
The text that needs to be kept is available as the (first) replacement string (typically \1).
Here is an example; the text to be processed is:
<table>
<tr>
<td>row1</td>
<td>row2</td>
</tr>
</table>
Using the regular expression:
(?:^.*<td>(.*)</td>.*$)|^.*\r?\n
with \1 as the replacement string will result in:
row1
row2
Notice that there are many implementation of regular expression using slightly different implementations. I use this type of regular expressions frequently with EditPadPro.
No comments:
Post a Comment