如何将以下 Js 正则表达式转换为 C#
let regex = /^([+]?\d{1,2}[.-\s]?)?(\d{3}[.-]?){2}\d{4}$/;
此模式与以下国际手机号码匹配
044668180099,
+49-691-234-5678,
+90-537-325-2345,
90-537-566-7152,
我想用 C# 进行相同的匹配
请指教
最佳答案
删除字符串开头和结尾处的“/”。
Regex.Match(yourline, @"^([+]?\d{1,2}[.\-\s]?)?(\d{3}[.-]?){2}\d{4}$");
See also this page about Regex.Match() from the microsoft docs for more overloads.
关于javascript - 正则表达式 从 Js 转换为 C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60850480/