Another one for the Regex gurus

  • Thread starter Thread starter Derrick
  • Start date Start date
D

Derrick

I am attempting to perform some word/phrase tagging, using regular
expressions.

I have the simple case working, looking for the string "one two three" in
the string "one two three four three two one"

My code is then tagging the match and surrounding it with braces, so I would
end up with

"$MATCH1{one two three} four three two one"

Down the line I wind up searching for the single word, "two", but do not
want to match the first occurence which is enclosed within curly braces.

Can anyone help me with the expression to match the second "two" in the
above string, but not the first, which is enclosed within curly braces, but
does not necessarily have the enclosing curly braces right next to the
string you are searching for?

The farthest I could get was something along the lines of

[^{] .+ two .+ [^}]

?

Thanks a bunch in advance!

Derrick
 
Your example seems fine. Is there a reason it's not working for you? What is the side effect?
 
Back
Top