Regex Find and Replace in MSVS 2008
I have a function I want to replace in this manner
myDictionary.Add("variable_key", "constant_value");
After replace, I want it to become
myDictionary.Add("variable_key", variable_key);
I tried to use
Add("{[.]+}", "constant_value");
replace to
Add("\1", \1);
But it cannot find the line. What am I missing? Please excuse me if this is a noob question. I always always have problems with regex. I just cannot understand them....
[]
creates a character class, matching the literal characters between the brackets.
Therefore, [.]
matches only the .
character.
You want to write .
, not inside of []
.
You also need to escape the parentheses with \
.
精彩评论