是否可以解析特定字符可用的字符串? [英] Is it possible to parse a string where specific character is available?
问题描述
如果我得到任何。(点)符号,我想解析一个字符串。
假设我的字符串就是这样。
I want to parse a string if i get any .(dot) sign available.
Suppose my string is like that.
String str="case when uniqesummaryofTTS.abc=0 OR 'apstps.bca=0' OR crUniquesummary.EndMarket=1 "
从这部分我总是喜欢到哪里。(点)可用。我没有必要考虑是否有。(点)可用''。
假设以下字符串我想得到uniqesummaryofTTS.abc和crUniquesummary.EndMarket 。虽然。(点)在apstps.bca中可用,但我不需要考虑它因为它在''。
From this portion i always like to get where .(dot)is available. I have no need to consider if there is .(dot) available in ''.
Suppose for the following string i want to get uniqesummaryofTTS.abc and crUniquesummary.EndMarket. Although .(dot) is available in apstps.bca, but i don'y need to consider it because it is in a ' '.
推荐答案
string input = "case when uniqesummaryofTTS.abc=0 OR 'apstps.bca=0' OR crUniquesummary.EndMarket=1 ";
string output = Regex.Replace(input, @"'(.+?)'", "");
string[] results =output.Split(new char[]{' ', '='}).Where(x=>x.Contains(".")).ToArray();
ref:
http://stackoverflow.com/问题/ 11121629 / c-sharp-regex-need-help-removal-text-from-quotes [ ^ ]
http://www.dotnetperls.com/regex-replace [ ^ ]
http://msdn.microsoft.com/en-us/library /b873y76a(v=vs.110).aspx [ ^ ]
http://msdn.microsoft.com/en-us/library/dy85x1sa(v = vs.110).aspx [ ^ ]
ref:
http://stackoverflow.com/questions/11121629/c-sharp-regex-need-help-removing-text-from-quotes[^]
http://www.dotnetperls.com/regex-replace[^]
http://msdn.microsoft.com/en-us/library/b873y76a(v=vs.110).aspx[^]
http://msdn.microsoft.com/en-us/library/dy85x1sa(v=vs.110).aspx[^]
请参阅 String.IndexOf
方法 [ ^ ]。您应该首先查看文档以了解可用的方法。
See String.IndexOf
Method[^]. You should always look at the documentation first to see what methods are available.
这篇关于是否可以解析特定字符可用的字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!