Query to find some word that is part of multiple different word in Notepad++



  • Hi,

    Could anyone please help me for below query in Notepad++

    Query: Is it possible to find some word that is part of multiple different word in Notepad++?

    Example : we have below example and we have to find word “vpls” and want my output with “vprn” details

    vprn 6000 customer 1 create
    exit
    vpls 100 customer 1 create
    description “IUB_KKRML03_VPLS”
    exit
    vpls 101 customer 1 create
    description “IUCS_KKRML03_VPLS”
    exit
    vprn 3000 customer 1 create
    vpls 102 customer 1 create
    exit
    vprn 2000 customer 1 create
    exit
    vpls 400 customer 1 create
    description “IUB_KKRML03_VPLS”
    exit
    vpls 301 customer 1 create
    description “IUCS_KKRML03_VPLS”
    exit
    vprn 7000 customer 1 create
    vpls 702 customer 1 create
    exit

    Expected Qutput :

    vprn 6000 customer 1 create
    vpls 100 customer 1 create
    vpls 101 customer 1 create
    vprn 3000 customer 1 create
    vpls 102 customer 1 create
    vprn 2000 customer 1 create
    vpls 400 customer 1 create
    vpls 301 customer 1 create
    vprn 7000 customer 1 create
    vpls 702 customer 1 create

    Hope to hear from you soon!!..



  • Hello, Manorma Gautam,

    Not very difficult !

    From what you said, I deduced some points :

    • You want to keep the lines, which contain, either, the string vprn OR vpls

    • These two words begin by the two lowercase letters vp

    • These two words are always located at beginning of lines

    • All the lines, which do not contain these two words, must be deleted


    So, follow the few steps, below :

    • Move back to the very beginning of your file ( Ctrl + Origin )

    • Open the Replace dialog (Ctrl + H )

    • In the Find what zone, type in (?-is)^(?!vp).+\R

    • Leave the Repalce with zone EMPTY

    • Uncheck, preferably, the Wrap around option

    • Select the Regular expression search mode

    • Click on the Replace All button

    Et voilà !

    NOTES :

    • The first part of the regex are in-line modifiers (?-is) to force the regex engine to consider the search :

      • In a non-insensitive way ( in the case you, previously, unchecked the March case option

      • With the dot symbol matching standard characters, exclusively, in the case you, previously, checked the . matches newline** option

    • The middle part ^(?!vp) looks, from beginning of each line, for a negative look-ahead ( a condition that must be true in order to satisfy the overall match but which is not part of the final regex. So, it verifies, for each line, if the exact string vp does NOT occur, at beginning of lines. If it’s the case :

    • The last part, of this regex, .+\R matches any non-null range of standard characters, from beginning of line, followed by any kind of EOL characters. That is to say any complete line, which does NOT begin with vp

    • All these complete lines are, of course, deleted, as the replacement part has been left EMPTY

    REMARK : The important thing, to note, is that look-arounds ( look-behinds and look-aheads ) do NOT move the regex engine position of search. So, after evaluating the negative look-ahead (?!vp) , the regex engine position is, still, just before the first character of each line ! Therefore, the part .+ does match all the standard characters of each line !

    Best Regards,

    guy038


Log in to reply