[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