I want to match exactly to loves and not to dloves or lovesd,
The regex used
(?<=>.*)loves(?=.*<)
Input samples:
<h1>loves</h1> -highlight loves
<h2> loves </h1> -highlight loves
<h3>dloves</h3> - ignore
<li> loves</li> -highlight loves
<li>loves </li> -highlight loves
<variable>lovesd</variable> - ignore lovesd
<h2 class="loves">loves</h2> - ignore the loves in within <h2 class="loves">, but highlight the loves outside it
Hi @hansen_Lobo
To match the exact word “loves” and exclude cases like “dloves” or “lovesd” can you try:
(?<=^|[^a-zA-Z0-9_\-])loves(?=[^a-zA-Z0-9_\-]|$)
Best regards
Roman
Yoichi
(Yoichi)
4
Hi,
How about the following?

System.Text.RegularExpressions.Regex.Matches(yourString,"(?<![\w""])loves(?![\w""])")
Regards,
postwick
(Paul Ostwick)
6
Why are you trying to parse the HTML instead of opening the web page in a browser and using activities to get the data you want?
system
(system)
Closed
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.