开发者

Regex Find and Replace in MSVS 2008

开发者_StackOverflow中文版

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 \.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜