如何使用VS2013正则表达式替换添加其他属性?

时间:2014-10-01 14:42:36

标签: regex visual-studio visual-studio-2013

需要更换:

 yield return new Question {QuestionID = 274, QuestionDescription = "WIF15 Notes to solicitor", QuestionCategoryId = 6, QuestionTypeID = 2};

 yield return new Question {QuestionID = 274, QuestionDescription = "WIF15 Notes to solicitor", QuestionText = "WIF15 Notes to solicitor", QuestionCategoryId = 6, QuestionTypeID = 2};

到目前为止尝试了

查找内容:

 QuestionDescription = \"{.*}\",

替换为:

QuestionDescription = "(\1)",  QuestionText = "(\1)",

说无法找到QuestionDescription = \" {。*} \",

2 个答案:

答案 0 :(得分:2)

正则表达式:

QuestionDescription = "([^"]*)",

替换字符串:

QuestionDescription = "$1",  QuestionText = "$1",

答案 1 :(得分:0)

自己完成

查找内容:

QuestionDescription = "(.*)",

替换为:

QuestionDescription = "$1",  QuestionText = "$1",