string text = "/08492184982/abc.gif";
Regex regex = new Regex(@"\/([.^\/]+)\/abc\.gif$", RegexOptions.IgnoreCase);
MatchCollection matchCollection = regex.Matches("/08492184982/abc.gif");
if (matchCollection.Count == 1){
string redfont = matchCollection[0].Groups[0].Value;
Console.WriteLine("红色的字是:" + redfont );
}
这个一直匹配不到红色的字,请大家帮忙
Regex regex = new Regex(@"\/([.^\/]+)\/abc\.gif$", RegexOptions.IgnoreCase);
MatchCollection matchCollection = regex.Matches("/08492184982/abc.gif");
if (matchCollection.Count == 1){
string redfont = matchCollection[0].Groups[0].Value;
Console.WriteLine("红色的字是:" + redfont );
}
这个一直匹配不到红色的字,请大家帮忙
var val = Regex.Match(text, "/(.*?)/abc.gif").Groups[1].Value;
var val = Regex.Match(text, "/(.*?)/abc.gif").Groups[1].Value;这个没有排除 / 这个符号
var val = Regex.Match(text, "/([^/\\]+?)/abc.gif").Groups[1].Value; /sadfsfs/fsadfs/imsi.gif 这一种情况,和上面的模式一样。
Regex regex = new Regex(@"\/([^\/]+)\/abc\.gif$", RegexOptions.IgnoreCase);
MatchCollection matchCollection = regex.Matches("/08492184982/abc.gif");
if (matchCollection.Count == 1){
string redfont = matchCollection[0].Groups[0].Value;
Console.WriteLine("红色的字是:" + redfont );
}
这个一直匹配不到红色的字,请大家帮忙
{ string seq = "string text = \"/08492184982/abc.gif";
regex rgx("\\d+(?=/)"); regex_iterator<string::iterator> it(seq.begin(),seq.end(),rgx);
regex_iterator<string::iterator> end;
short cnt=0;
vector<int> v_int;
while (it!=end)
{
cout<<++cnt<<"\t:";
v_int.push_back(strtol(it->str().c_str(),NULL,10));
cout<<it++->str()<<endl;
}
}
str = Regex.Match(str, @"(?is)(?<=/)[^/]+(?=/[\w_]+\.[a-z0-9]+/?$)").Value;