Regex - find only replace occurences not touching some of them

Posted by vittore on Stack Overflow See other posts from Stack Overflow or by vittore
Published on 2010-04-02T23:58:34Z Indexed on 2010/04/03 0:03 UTC
Read the original article Hit count: 401

Filed under:
|
|
|

Not very good at regex though and maybe that's a stupid question,

I'm given string like "bla @a bla @a1 bla "

I'm also pairs like {"a", "a2"} , {"a1", "a13"}, and am to replace @a to @a2 for first pair, and @a1 to @a13 for second one. The problem is when i use string.replace and look for @a , it also replaces @a1 but it should not. Help me with regex replace, please.

Cheers

© Stack Overflow or respective owner

Related posts about regex

Related posts about replace