Searching two words on different lines



  • Hi,

    I need to search for the word new_task and the word task_pending which is supposed to be 3 lines after new_task. How can i do this? Thanks for any help.



  • Hello, @kyle-warren and All,

    Not difficult with regular expressions !

    Two possibilities :

    • The first regex (?-si)new_task(.+\R){3}.*task_pending searches for the range of any character between the two strings new_task and task_pending, with that exact case

    • The second regex (?-si)^.*new_task(.+\R){3}.*task_pending.*\R? searches for the complete block of 4 lines containing, both, the strings new_task and task_pending, with this exact case

    Best Regards

    guy038


  • Banned

    Hello,@Kyle-Warren

    Please follow this information,To Searching two words on different lines

    You need a new version of notepad++. Looks like old versions don’t support |.

    Note: egrep “CAT|TOWN” will search for lines containing CATOWN. (CAT)|(TOWN) is the proper or extension (matching 1,3,4). Strangely you wrote and which is btw (CAT.*TOWN)|(TOWN.*CAT)

    I hope this information will be useful for you.
    Thank you.



  • Like most of @Makwana-Prahlad 's posts, this one deeply confuses me.

    You need a new version of notepad++. Looks like old versions don’t support |.

    Misinformation, unless by “old” you mean pre-6.0.
    But why would you assume OP is using a really old version anyway – the OP didn’t say what version, but…

    egrep

    What does that have to do with anything??

    egrep “CAT|TOWN” will search for lines containing CATOWN.

    What does that have to do what the OP is needing to do?

    I could pick apart the rest of the posting, but it is getting tiring.
    Just please, don’t spread misinformation.


Log in to reply