1 回答
TA贡献2051条经验 获得超10个赞
matches part of a string:
Regex.IsMatch(subjectString, "(13|14|15|17|18)[0-9]{1}[0-9]{8}", RegexOptions.IgnoreCase | RegexOptions.Multiline)
or get the part of a string:
Regex.Match(subjectString, "(13|14|15|17|18)[0-9]{1}[0-9]{8}", RegexOptions.IgnoreCase | RegexOptions.Multiline).Value
maybe your are iterate over all matches in a string:
try {
var regexObj = new Regex("(13|14|15|17|18)[0-9]{1}[0-9]{8}", RegexOptions.IgnoreCase | RegexOptions.Multiline);
Match matchResults = regexObj.Match(subjectString);
while (matchResults.Success) {
// doing
matchResults = matchResults.NextMatch();
}
} catch (ArgumentException ex) {
// Syntax error in the regular expression
}
添加回答
举报