Dan Craciun
asked on
Regular expression
Looks like my understanding of negative lookaheads is lacking.
I have this test string:
I want to match "text" followed by "code" in the same row.
That is, "code" should follow "text" before "<\tr>".
In the sample, the only match should be
How can I write the regular expression for that?
I have this test string:
<tr>
<td>text</td>
<td></td>
<td>code</td>
</tr>
<tr>
<td>text</td>
</tr>
<tr>
<code>
</tr>
and the following expression:(?sm)<tr>.*?(text).*?(code).*?</tr>
I want to match "text" followed by "code" in the same row.
That is, "code" should follow "text" before "<\tr>".
In the sample, the only match should be
<tr>
<td>text</td>
<td></td>
<td>code</td>
</tr>
How can I write the regular expression for that?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I kept writing the lookahead as
(?:.*(?!</tr>))
and it refused to work.
Thank you, kaufmed.