java - Regex positive look behind for regex reverse matching? -


how can match string literal reverse direction match string literal above it?

basically match "match" behind , match "here:" match "here:" end of string (to delete)

-- input --

keep  here: match test test  should deleted 

-- expected output (after match , delete) --

   keep 

demo

you don't need make movement, need find "here:" , ensure string contains "match" after (if not case, pattern fail):

(?s)here:.*?match.* 

(?s) dot can match newlines

however, if possible, obtain better performances using indexof method "match" , "here:", comparing result , cuting string @ index of "here:"


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -