Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to parse a string if i get any .(dot) sign available.

Suppose my string is like that.

C#
String str="case when uniqesummaryofTTS.abc=0 OR 'apstps.bca=0' OR crUniquesummary.EndMarket=1 "


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 ' '.
Posted
Updated 20-May-14 22:09pm
v2

C#
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/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[^]
 
Share this answer
 
v2
Comments
Ankur\m/ 21-May-14 4:36am    
That should help. 5!
DamithSL 21-May-14 4:38am    
Thank you Ankur
sachi Dash 21-May-14 5:45am    
hello if
input = "case when DateDiff (uniqesummaryofTTS.abc=0) OR 'apstps.bca=0' OR crUniquesummary.EndMarket=1"

Then it doesn't work.
sachi Dash 21-May-14 5:46am    
For the same case i also need uniqesummaryofTTS.abc and crUniquesummary.EndMarket
Matt T Heffron 21-May-14 17:16pm    
Just add all the possible other delimiters to the array passed to: output.Split(new char[]{' ', '=', '(', ')'})
See String.IndexOf Method[^]. You should always look at the documentation first to see what methods are available.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900