Community
    • Login

    How to search between multiple lines in Notepad++ ??

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 6.0k 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.
    • Prahlad-Makwana4145P
      Prahlad-Makwana4145
      last edited by Prahlad-Makwana4145

      Hello, Everyone

      I am trying to perform a search between multiple lines and also delete selected text.
      Example show below :-

      I want to start a search from this word “Description This:” To “<h3>” select all text and delete it.
      When i search in 1st line i have used .*?.*

      Description This: 
                      Hello everyone.
                      How are you ?
                      Where are you ?
                      I am going to School please come with me.
                      Thank you for everything.
                      <h3>
                      Good to see you.
      

      Thank you in advance.

      1 Reply Last reply Reply Quote 0
      • guy038G
        guy038
        last edited by guy038

        Hello, Prahlad-Makwana4145 and All,

        Hi, Happy New Year 2020 !


        Regarding your problem, two solutions are possible :

        • SEARCH (?-i)^Description(?s).*?<h3>\R

        OR

        • SEARCH (?-i)^Description(.|\R)*?<h3>\R

        • REPLACE Leave EMPTY

        • Tick the Wrap around option and select the Regular expression search mode

        • Use either the Replace All or the Replace button

        Notes :

        • First, the in-line modifier (?-i) forces the search to care about casing of letters

        • After the part ^Description looks for the word Description, with that exact case, at beginning of lines

        • Then the part (?s), an in-line modifier too, means that any subsequent regex . symbol will match any single character, including EOL ones

        • Now, the part .*? represents the shortest range of any character till…

        • The part <h3>\R which matches an <h3> tag with its ine-break ( \R)

        • As replacement is empty, any text matched is just deleted

        • In the second search form, we replace the part (?s). with (.|\R) which stands, in the same way, for a single standard or an EOL character

        Best Regards,

        guy038

        Prahlad-Makwana4145P 1 Reply Last reply Reply Quote 2
        • Prahlad-Makwana4145P
          Prahlad-Makwana4145 @guy038
          last edited by

          Hello, Happy New Year 2020 ! @guy038 and All,

          Thank you for Replay your both solution are work successfully for me.

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