string a = @"fdsafdsfd@A fdasf "; Regex re = new Regex(@".*(?<=@A)"); MatchCollection mac = re.Matches(a); foreach (Match m in mac) { Console.WriteLine (m.Value); } Console.ReadKey();
String str = @"<df@s <df>@A"; Regex re = new Regex(@"(?<=@A)$"); return re.IsMatch(str);
.+(@A)就是匹配所有以@A结束的字符串。。例如:!@@!#@A
//Try it.
Regex re=new Regex(@"(?<=@A)$");
{
//to do...
}
应该怎么整啊?
Regex re = new Regex(@".*(?<=@A)");
MatchCollection mac = re.Matches(a);
foreach (Match m in mac)
{
Console.WriteLine (m.Value);
}
Console.ReadKey();
String str = @"<df@s <df>@A"; Regex re = new Regex(@"(?<=@A)$"); return re.IsMatch(str);
再次感谢这位兄弟,只不过 string@A string2@A是这样的格式,用MatchCollection这总是贪婪的匹配。
是要验证字符串是合法,还是要找到其中XXXX@A的字符串
如果是验证:[\s\S]*?@A$
如果只是要取:[\s\S]*?@A
应该这样
正则:.*?@A
结果:
sdjklf@A
slkajdf@A
skjdf @A
sjkfla jk@A
.*?(?=@A)不带@A的正则