-1

I'm trying to find a multilined string inside of HTML tags. This regex

<\s*form[^>]*>(.*?)<\s*/\s*form>

does it pretty well in Notepad++, if the setting find \r and \n is activated.

What i can't get done is to force this regex to work with Excel (using a .Net Addon, which lets execute regex). There this regex finds only one lined string (mean without \r, \n or both).

For example:

  • if a string is <form foo>bar</form> - regex finds bar, as expected,
  • If a string is <form foo>bar\r\nbaz</form> - regex finds nothing.

How could this regex be adjusted to catch multilined strings too?

Jeroen
  • 53,290
  • 30
  • 172
  • 279
Evgeniy
  • 1,838
  • 18
  • 41
  • Maybe you can use a real html parser in your .net addon – Tim Schmelter Mar 13 '17 at 10:39
  • @TimSchmelter i can't :( – Evgeniy Mar 13 '17 at 10:41
  • If you feel the question isn't a duplicate it's best to make an edit to further explain how it's different and/or why the solutions from the other question don't apply here. – Jeroen Mar 13 '17 at 19:39
  • @Jeroen i don't need these ego games editors are playing here. Who is looking for described solution, will find it, with or without a notice, that an editor has a shmock he likes to publicly demonstrate. If you value this community, vote better for those who answered the question. – Evgeniy Mar 14 '17 at 07:49

1 Answers1

0

Provided the .Net Addon supports .NET Regex syntax, you may inject (?s) modifier into the expression to make the . match newline chars too:

(?s)<\s*form[^>]*>(.*?)<\s*/\s*form>
Dmitry Egorov
  • 9,137
  • 3
  • 19
  • 36