I have following string
sssHi this is the test for regular Expression,sr,Hi this is the test for regular Expression
I would like to replace only
Hi this is the test for regular Expression
segment with some other string.
the first segment in string "sss Hi this is the test for regular Expression" should not be replaced
I wrote following regex for the same :
/([^.]Hi\sthis\sis\sthe\stest\sfor\sregular\sExpression)|(Hi\sthis\sis\sthe\stest\sfor\sregular\sExpression)$/
but it matches both segments. I want to match only the second one as first segement is prefixed by "sss".
[^.]
should match nothing except newline right? So group
"([^.]anystring)"
should only match "anystring" that is not preceded by any chanrachter except newline. Am I correct?
any thoughts.
\b. e.g.\b(Hi this is the test...)\blookaheadandlookbehindassertion herelookaheadcan be useful