[英]Regex Regular expression in c#
We have implemented the invocation of brill tagger from our c# code. 我们已经从c#代码中实现了brill tagger的调用。 We just neede to know what is the correct Regex regular expression for eliminating all from a string, but jst keep az,AZ, full stop and comma.
我们只需要知道正确的正则表达式正则表达式是什么就可以消除字符串中的所有内容,但是首先保留az,AZ,句号和逗号。 We tried
[^a-zA-Z\\.\\,]
on the online regular expression tester and it is giving the correct result, but when implemented in C#, it is not working properly. 我们在在线正则表达式测试器上尝试了
[^a-zA-Z\\.\\,]
,它给出了正确的结果,但是在C#中实现时,它无法正常工作。 We also tried several other combinations but we are not getting the correct result. 我们还尝试了其他几种组合,但未获得正确的结果。
This is the format in which we are writing: 这是我们编写的格式:
strFileContent = Regex.Replace(strFileContent, @"[^a-zA-Z\.\,]", "");
but we are not getting the desired output. 但是我们没有得到想要的输出。 what is wrong??
怎么了??
Regex.Replace(yourString, @"[^az\\.\\,]", string.Empty, RegexOptions.IgnoreCase)
EDIT: I can't see anything wrong with what you are doing, my answer is exactly the same. 编辑:我看不到您在做什么,我的答案是完全相同的。 I tested both in LINQPad and they both return the same result.
我在LINQPad中进行了测试,它们都返回相同的结果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.