regex - Notepad++ Removing text between two strings if third string is present between other strings -
i remove text between 2 strings, including strings, if , if third string present between 2 strings. prefer if use replace functionality in notepad++ this.
here's mock-up of need altered:
asdfnjaslfjsa asdfjaskldfsafkldj asdfjsadfk string_1 sanjvnlamf fas g gsegvrs string_2 string_1 asf sf gfsjasak qweuwiouqnv string_3 awi iavbfa c anfiab string_2 string_1 asmorancm anib fas string_2 sdabfashbdfbc ds
changed this:
asdfnjaslfjsa asdfjaskldfsafkldj asdfjsadfk string_1 sanjvnlamf fas g gsegvrs string_2 string_1 asmorancm anib fas string_2 sdabfashbdfbc ds
what looking can achieved following construct:
string_1 (?:(?!string_2)[\s\s])*? string_3 (?:(?!string_2)[\s\s])*? string_2
this matches string_1
string_2
if string_3
present in between (the technique called tempered greedy token).
can put in 1 line well:
string_1(?:(?!string_2)[\s\s])*?string_3(?:(?!string_2)[\s\s])*?string_2
Comments
Post a Comment