Help with regex for multiline

Hello Community, i want to replace a word love with hates in a multi line,
The regex that i use:

(?<=>.*)(?<!\w)loves(?!\w)(?=.*<)

Input samples:

<p>hello i am human,
loves dogs.
</p>  - highlights loves in 2nd line
<p>hello i am human,
loves dogs.</p>  - highlights loves in 2nd line
<h1>loves dsdfsf</h1> -highlight loves
<h2>fdsfsd 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">,

@hansen_Lobo
Hi Try this one. I know its second post for this one. Hopefully now you will be able to replace your data.

1 Like

Thank you, This one works!!!

1 Like

@hansen_Lobo Happy Automation.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.