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



  • 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.



  • 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



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

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


Log in to reply