Click here to Skip to main content
15,903,201 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Find mobile number from string c#

for Ex my string is ",38,,,,,,,,,,,,,,,,,,,,,,,,,,,,382350,,,,,0,,,,8141884584,,,,,,,,"

now i want result "8141884584" by Regex or any other function
Posted
Comments
Sushil Mate 1-Aug-13 3:09am    
You need to learn about Regex then. I must say.

RegEx.Split("\d{10}") could be the key.

Check this link

http://forums.asp.net/t/1278991.aspx/1[^]
 
Share this answer
 
 
Share this answer
 
Seems like a list of comma delimited values to me. If the mobile number have a fixed place in the list, you can split the string into separate fields and access the required field by its index:
C#
string foo = ",38,,,,,,,,,,,,,,,,,,,,,,,,,,,,382350,,,,,0,,,,8141884584,,,,,,,,";
string[] bar = foo.Split(',');
MessageBox.Show(bar[38]);
 
Share this answer
 
C#
string strData=",38,,,,,,,,,,,,,,,,,,,,,,,,,,,,382350,,,,,0,,,,8141884584,,,,,,,,";


C#
char[] separator = new char[] { ','
string[] strSplitArr = strData.Split(separator);


C#
for (int q = 0; q < strSplitArr.Length; q++)
        {
            if (strSplitArr[q] != "")
            {
                int no = 0;

                no = strSplitArr[q].Length;
                if (no >= 10 && no <= 12)
                {
                    numString += strSplitArr[q].ToString() + ", ";
                }
            }
        }
 
Share this answer
 
v2

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