Community
    • Login

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

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    2 Posts 2 Posters 3.1k 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.
    • semicodinS Offline
      semicodin
      last edited by

      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
      • guy038G Offline
        guy038
        last edited by guy038

        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

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        The Community of users of the Notepad++ text editor.
        Powered by NodeBB | Contributors