[username]其中username是含长1到12个字符之间只有字母数字字符的任意字符串正则表达式模式 - 字母
我的代码:
Regex pat = new Regex(@"\[[a-zA-Z0-9_]{1,12}\]");
MatchCollection matches = pat.Matches(accountFileData);
foreach (Match m in matches)
{
string username = m.Value.Replace("[", "").Replace("]", "");
MessageBox.Show(username);
}
给了我一个空白匹配
注意你的语言。它是如何工作的? – 2011-04-04 16:04:40
为什么两组方括号? – Toby 2011-04-04 16:04:49