2

I have the folowing HTML:

<Some Html above....../>
<!--Template Start -->
<div>
<p>Some text</p>
...
<div>
<!--Template End -->
<Some Html below/>

Now how can I write regular expression to match all text from Template Start to Template End

here it says that notepad++ use Scintilla engine. Notepad++ non-greedy regular expressions

Community
  • 1
  • 1
jasin_89
  • 1,993
  • 7
  • 30
  • 41

3 Answers3

9
<!--Template Start -->(.*?)<!--Template End -->

s modifier should be switched on.

Karolis
  • 9,396
  • 29
  • 38
2

Assuming that there are no nested templates:

<!--Template Start -->(.*?)<!--Template End -->

Note to switch on mode DOT_ALL to also cover newlines.

Howard
  • 38,639
  • 9
  • 64
  • 83
0

It's a shame, but Notepad++ doesn't support matching newlines (\r\n) natively in regex mode. It does support matching newlines only in extended mode. However it DOES support INSERTING newlines in both modes.

To achieve desired results, you can do a workaround:

  1. Delete all newlines in extended mode (replace \r\n with nothing) so you have one-liner.
  2. Do regex manipulations in regex mode.
  3. Add newlines back in extended mode (e.g. replace <div> with <div>\r\n and so on) or regex mode.

I've read somewhere that PythonScript plugin for N++ adds better support for regexes but I haven't checked it.

jakub.g
  • 38,512
  • 12
  • 92
  • 130