输入是55
,我的正则表达式是^(5{2})$
。所以理想情况下(至少对我来说)这应该返回每个以 5 开头并以 5 结尾的字符串,对吧?
但是当我的 c# 如下:
Match match = Regex.Match(input, String.Format(@"{0}", regex));
string outcome = null;
if (match.Success)
{
for (int i = 0; i < match.Groups.Count; i++)
{
outcome += match.Groups[i].Value;
}
}
为什么我的字符串outcome
返回 5555 而不是 55?
当我从正则表达式中删除括号时,它可以完美运行。