@"@.[abc|123]."可以demo:
MatchCollection mc;
String[] results = new String[20];
int[] matchposition = new int[20];
// Create a new Regex object and define the regular expression.
Regex r = new Regex(@"@.[abc|123].");
// Use the Matches method to find all matches in the input string.
mc = r.Matches(@"asd'asd fw@123abc4abcd@asdfas");
// Loop through the match collection to retrieve all
// matches and positions.
for (int i = 0; i < mc.Count; i++)
{
// Add the match string to the string array.
results[i] = mc[i].Value;
// Record the character position where the match was found.
matchposition[i] = mc[i].Index;
Console.WriteLine(mc[i].Index);
}
MatchCollection mc;
String[] results = new String[20];
int[] matchposition = new int[20];
// Create a new Regex object and define the regular expression.
Regex r = new Regex(@"@.[abc|123].");
// Use the Matches method to find all matches in the input string.
mc = r.Matches(@"asd'asd fw@123abc4abcd@asdfas");
// Loop through the match collection to retrieve all
// matches and positions.
for (int i = 0; i < mc.Count; i++)
{
// Add the match string to the string array.
results[i] = mc[i].Value;
// Record the character position where the match was found.
matchposition[i] = mc[i].Index;
Console.WriteLine(mc[i].Index);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货