4

Better explain with an example.

This is text:

<li>hello 
THE WORDS
</li>

<li> cruel </li>

<li> world THE WORDS </li>

I want to find strings start with <li> and ends with </li> and contains THE WORDS. I am expecting to only match with <li> hello THE WORDS </li> and <li> world THE WORDS </li>.

What I tried: (?s)<li>.*?(THE WORDS).*?</li>

With this, second match is <li> cruel </li> <li> world THE WORDS </li>.

I am using Sublime Text.

MattDMo
  • 100,794
  • 21
  • 241
  • 231
previous_developer
  • 10,579
  • 6
  • 41
  • 66
  • I believe your "example" its making it more difficult than the actual data. Are the line breaks always at the positions as in your example? Can the strings "xx" and "yy" appear inside the lines? – RoToRa Jul 10 '14 at 10:32
  • @RoToRa I updated my example. Line breaks can be anywhere except "THE WORDS" and "
  • " parts, there is no "
  • " in text. – previous_developer Jul 10 '14 at 12:19
  • Ah, very, very, very different situation there. First remark has to be: You shouldn't be using regular expressions with HTML. Why do you have to use Sublime here? Considering this is HTML, JavaScript in a browser would be a better choice. – RoToRa Jul 10 '14 at 12:44