最佳答案
还有比这更好的方法将 MatchCollection 转换为字符串数组吗?
MatchCollection mc = Regex.Matches(strText, @"\b[A-Za-z-']+\b");
string[] strArray = new string[mc.Count];
for (int i = 0; i < mc.Count;i++ )
{
strArray[i] = mc[i].Groups[0].Value;
}
附注: mc.CopyTo(strArray,0)
抛出一个异常:
源数组中至少有一个元素无法强制转换为目标数组类型。