• Login
Community
  • Login

Finding html tags and everything between them on >>multiple lines?

Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
2 Posts 2 Posters 2.8k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S
    semicodin
    last edited by Apr 17, 2017, 10:56 PM

    Can Notepad++ find (for example):
    <script> some stuff some more stuff (new line)
    and more stuff </script>

    I’m trying to get rid of the bloat-code on an HTML document. Thanks for any help!

    1 Reply Last reply Reply Quote 0
    • G
      guy038
      last edited by guy038 Apr 18, 2017, 7:18 PM Apr 18, 2017, 7:16 PM

      Hello, @semicodin,

      The correct regex to match any range of characters, even on several lines, with the syntax :

      - <script .....>................... </script>
      
      or :
      
      - <script> ........................ </script>
      

      is (?s-i)<(script)( |>).*?</\1>


      Notes :

      • The initial part (?s-i) are modifiers, which forces the regex engine to consider that :

        • The special dot character can match, absolutely, any character ( Standard or End of Line characters )

        • The search will be performed in a sensitive way ( = non-insensitive )

      • Then, the first part <(script)( |>) tries to match, either, the string <script> OR the string <script, followed with a space character. Note that the word script, embedded in round parentheses, stands for group 1

      • The third part </\1> matches the exact string </script>

      • And the second part .*? represents the shortest range of any character between part 1 and part 3

      IMPORTANT :

      Don’t forgot that this simple regex supposes that no other block <script......</script> is nested, inside the initial block !

      Best Regards,

      guy038

      1 Reply Last reply Reply Quote 1
      1 out of 2
      • First post
        1/2
        Last post
      The Community of users of the Notepad++ text editor.
      Powered by NodeBB | Contributors