C# 从给定字符串c中查找电话号码#

C# 从给定字符串c中查找电话号码#,c#,asp.net,regex,string,C#,Asp.net,Regex,String,我有一份简历,我想找到用户的联系电话(手机号码或电话号码) 从简历中,你需要任何想法、解决方案或帮助来实现目标 到目前为止我所尝试的 var numString = ""; string strData = ",38,,,,,,,,,,,,,,,,,,,,,,,,,,,,382350,,,,,0,,,,8141884584,,,,,,,,"; char[] separator = new char[] { ',' }; string[] strSp

我有一份简历,我想找到用户的联系电话(手机号码或电话号码) 从简历中,你需要任何想法、解决方案或帮助来实现目标

到目前为止我所尝试的

var numString = "";
        string strData = ",38,,,,,,,,,,,,,,,,,,,,,,,,,,,,382350,,,,,0,,,,8141884584,,,,,,,,";
        char[] separator = new char[] { ',' };
        string[] strSplitArr = strData.Split(separator);
        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() + ", ";
                }
            }
        }
var numString=“”;
字符串strData=“,38,,,,,,,,,,,,,,,,,,,,,,,,382350,,,,,,,0,,,,,8141884584,,,,,,,,,,”;
字符[]分隔符=新字符[]{',};
字符串[]strsplitar=strData.Split(分隔符);
for(int q=0;q如果(no>=10&&no,我建议您使用

以下是查找美国电话号码的示例代码:

string text = MyInputMethod();
const string MatchPhonePattern =
       @"\(?\d{3}\)?-? *\d{3}-? *-?\d{4}";

        Regex rx = new Regex(MatchPhonePattern, RegexOptions.Compiled | RegexOptions.IgnoreCase);

        // Find matches.
        MatchCollection matches = rx.Matches(text);

        // Report the number of matches found.
        int noOfMatches = matches.Count;


        //Do something with the matches

        foreach (Match match in matches)
        {
            //Do something with the matches
           string tempPhoneNumber= match.Value.ToString(); ;

         }

@Izzy请查看更新后的postJust使用正则表达式模式,如
,[\d]{10},
您的示例数据看起来不像简历。您向我们展示拆分CSV字符串的代码有什么原因吗?仅供参考,该代码可以缩减为
var numString=string.Join(“,”,strData.Split(“,”)。其中(s=>s.Length>=10&&s.Length具有给定模式的任何示例代码@MacroMan@juharr我的方法不好,我想每个国家都有不同的模式吗?这取决于电话号码的格式。但我也在其他国家使用过这种方法:
@\(([0-9]{3})\)?[-.]([0-9]{3})[-.]([0-9]{4})