【发布时间】:2013-05-16 13:05:26
【问题描述】:
有几个字符串,我想从这些字符串中删除所有“R.G(**)”。例如:
1、原字符串:
Push("Command", string.Format(R.G("#{0} this is a string"), accID));
结果:
Push("Command", string.Format("#{0} this is a string", accID));
2、原字符串:
Select(Case(T["AccDirect"]).WhenThen(1, R.G("input")).Else(R.G("output")).As("Direct"));
结果:
Select(Case(T["AccDirect"]).WhenThen(1, "input").Else("output").As("Direct"));
3、原字符串:
R.G("this is a \"string\"")
结果:
"this is a \"string\""
4、原字符串:
R.G("this is a (string)")
结果:
"this is a (string)"
5、原字符串:
AppendLine(string.Format(R.G("[{0}] Error:"), str) + R.G("Contains one of these symbols: \\ / : ; * ? \" \' < > | & +"));
结果:
AppendLine(string.Format("[{0}] Error:", str) + "Contains one of these symbols: \\ / : ; * ? \" \' < > | & +");
6 、原字符串:
R.G(@"this is the ""1st"" string.
this is the (2nd) string.")
结果:
@"this is the ""1st"" string.
this is the (2nd) string."
请帮忙。
【问题讨论】:
-
R.G(...)项目是否总是只存在于一行中? -
另外,您是否需要能够应对例如
R.G("Hello)World")? -
不应该 this 为 current 示例工作吗?
-
正则表达式是这个工作的错误工具。一个简单的有状态解析器效果更好。
标签: c# .net regex expression