Wednesday 15 July 2015

Regex needed to get text between to words when text starting match appears earlier -



Regex needed to get text between to words when text starting match appears earlier -

i quite unexperienced in using regex. have text this:

this demo text need special part text want here.<

the result need : "text want get" .so have search backwards "get" "text" guess.

my regex (?<=text\s).*(?<=\bget) returning "i need special part text want get"

how can modify regex work backwards "get" "text"?

use negative lookahead assert "text" not appear 1 time again after starting "text" of match.

also, if want include "text" , "get", must match them (rather around them).

text(?!.*text).*\bget\b

see demo.

regex words lookbehind

No comments:

Post a Comment