Label3.Text="正则表达式:";
string text=
@"One x1car red y12car blue z123car";
string Pattem ="car\b";
MatchCollection Matches =Regex.Match(text,Pattem,RegexOptions.ExplicitCapture);
foreach(Match NextMatch in Matches)
{
Label3.Text+="<br>"+NextMatch.Index;
}书上是这么写的,可是看了一下Match的重栽函数,返回的都是Match
也就是MatchCollection Matches =Regex.Match(text,Pattem,RegexOptions.ExplicitCapture);
这句报错,说类型无法转换,显示转换也不可以。如何解决?
string text=
@"One x1car red y12car blue z123car";
string Pattem ="car\b";
MatchCollection Matches =Regex.Match(text,Pattem,RegexOptions.ExplicitCapture);
foreach(Match NextMatch in Matches)
{
Label3.Text+="<br>"+NextMatch.Index;
}书上是这么写的,可是看了一下Match的重栽函数,返回的都是Match
也就是MatchCollection Matches =Regex.Match(text,Pattem,RegexOptions.ExplicitCapture);
这句报错,说类型无法转换,显示转换也不可以。如何解决?
搞定了
第一个来的,分拿走吧