ASP.NET - how to get string after last special characters

Asked By anbu n on 28-Oct-11 12:19 PM
the string will be like this ,the below are examples,[ i need string after last special character]

5555,,5555,3   - here i need  string after last special chaaracter ie 3

45,56,8585895,, 88 - here i need  string after last special chaaracter ie 88
Santhosh N replied to anbu n on 28-Oct-11 12:45 PM
You could use string.split for this in c# with multiple chars..
string[] results = str.Split(new char[] { ',', '.', ' ' }, StringSplitOptions.RemoveEmptyEntries);

last one in results gives you the desired output..


Here you can add any number of chars you wish to add expecting the chars other than ,
dipa ahuja replied to anbu n on 28-Oct-11 01:08 PM
Try this simply 

string s = "5555,,5555,3";
 
string[] parse = s.Split(',');
 
Response.Write(parse[parse.Length - 1]); //RETURN 3