Regex - find and replace complete string occurrences only (not partial matches)
- by vittore
I'm not very good at regex but maybe there's a simple way to achieve this task.
I'm given a string like "bla @a bla @a1 bla"
I'm also given pairs like {"a", "a2"} , {"a1", "a13"}, and I need to replace @a with @a2 for the first pair, and @a1 with @a13 for the second one.
The problem is when i use String.Replace and look for @a, it also replaces @a1 but it should not. I need it to completely match @a and avoid partially matching it in other places.
Note: the given string could also be brackets, commas, dots and so on. However, pairs will always be [a-z]*[0-9]+
Help me with regex replace, please.
Cheers