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 

see a demo on regex101.com.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -