C#正则表达式分组使用

            string s = "dfasfdasfdsa*fdasfdsafdsa";
s = "转发:dfasfdasfdsa*fdasfdsafdsa";
//s = "转发:***dfasfdasfdsa*fdasfdsafdsa";
//s = "转发: dfasfdasfdsa*fdasfdsafdsa";
//s = "转发: * * * dfasfdasfdsa*fdasfdsafdsa"; MatchCollection mc = Regex.Matches(s, @"(转发:)*[\s|*]*(?<a>\S+)");
foreach (Match m in mc)
{
string s2 = m.Groups["a"].Value;
//s2 = dfasfdasfdsa*fdasfdsafdsa
}

分组中我们使用(?<a>\S+)表示一组

上一篇:Error creating bean with name 'student': Unsatisfied dependency expressed through field 'teacher'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating


下一篇:Angular 请求数据