By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,664 Members | 1,649 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,664 IT Pros & Developers. It's quick & easy.

Another one for the regex gurus

P: n/a

Hi Dave -

Thanks, I'll give an easier example, say I have:

sodium ion test

and I search for "sodium ion test", matching, tagging, I end up with, say

TEST${sodium ion test}

now if I go to search for just "ion", i don't want it to match because "ion"
is now within curly braces.

using [^{].+ion.+[^}] produces a match, which i don't want. If i put spaces
in the regex like so, [^{] .+ ion .+ [^}], then it doesn't match, but also
doesn't match simply "sodium ion test"

Basically, if I'm searching for "ion" here's the truth table I want to end
up with:

string match?
TEST${sodium ion test} no
sodium ion test yes
TEST${sodium} ion test yes
TEST${sodium} ion TEST${test} yes

Again, thanks in advance for any suggestions!


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

Dave Sexton
"Derrick" <de*********> wrote in message
I am attempting to perform some word/phrase tagging, using regular

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!


Nov 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.