4

I have the following string:

<ul><li><span>some words here.</span></li><li><span>other words here.</span></li><li><span>Code: 55555.</span></li></ul>

My goal is to remove this part from the string, the set of li tags which contain "code" keyword:

<li><span>Code: 55555.</span></li>

I am trying to write a RegEx that will help me match and replace my substring. Text in between <li></li> might vary but it will always have the keyword "Code". This is what I have so far:

<li>(.*)code:(.*?)<\/li>

The problem is, it matches from the first <li> tag and I want it to match starting from the <li> tag which is right before our keyword "code".

Thank you for your help!

Florin C.
  • 266
  • 7
  • 18
  • nope, there isn't any nesting within. – Florin C. Mar 17 '16 at 09:25