我想替换以下3行:
this.CSType = typeof(DateTimeOffset?);
this.CSTypeString = "Target";
this.MappedCSType = SQLTypes.MappedCSType.NullableDateTimeOffset;
有了这个:
result = "Target";
所以我尝试使用这个正则表达式:
查找::bthis.CSType = typeof(*);\n:bthis.CSTypeString = "{[^"]+}";\n:bthis.MappedCSType = SQLTypes.MappedCSType.*;
替换:result = "\1";
但是有一个错误:Grouped expression is missing ')'.
我的表情有问题吗?你的建议是什么?
答案 0 :(得分:0)
我认为你的正则表达式的问题在于你没有定义组。我想你试图通过使用{[^"]+}
对来定义组,这在语法上是不正确的。使用圆括号()
定义组。 typeof(*)
也不会与typeof(DateTimeOffset?)
匹配。
您可以尝试关注xpath
this.CSType = typeof\(.*\);\nthis.CSTypeString = "([^"]+)";\nthis.MappedCSType = SQLTypes.MappedCSType.*
注意一对圆括号([^"]+)
。该组即组1将匹配Target
字符串。您可以在http://regexpal.com
希望这有帮助