【发布时间】:2012-06-14 02:53:04
【问题描述】:
首先,我只能使用 C# 正则表达式,因此建议其他语言或非正则表达式解决方案将无济于事。现在提问。
我必须找到代码中的所有字符串(几千个文件)。基本上有6种情况:
string a = "something"; // output" "something"
sring b = "something else" + " more"; // output: "something else" and " more"
Print("this should match"); // output: "this should match"
Print("So" + "should this"); // output: "So" and "should this"
Debug("just some bebug text"); // output: this should not match
Debug("more " + "debug text"); // output: this should not match
正则表达式应该匹配前 4 个(我只需要引号内的内容,打印也可以是任何其他函数)
到目前为止,我有这个,它返回引号中的任何内容:
".*?"
【问题讨论】:
-
我建议您使用正则表达式工具来帮助您完成作业。我使用 expresso (ultrapico.com/Expresso.htm)。
-
你能给一些示例数据吗?或者您只想排除带有
"debug"的任何行? -
上面的输出应该是:“something”、“something else”、“more”、“this should match”、“So”、“should this”。我不想要的是“只是一些错误文本”、“更多”和“调试文本”
标签: c# regex regex-negation