const string pattern = @"\d+";//表达1位或多位的整数数字
private void ChangeText()
{
for (int x = 0; x < content.Count; x++)
{
var a = Regex.Matches(content[x], pattern).Cast<Match>().Select(m => m.Index).ToArray();
var b = Regex.Matches(content[x], pattern).Cast<Match>().Select(m => m.Value).ToArray();
for (int y = 0; y < b.Length; y++)
{
b[y] = "<size="+size+">" + "<color=#"+colorNum+">" + b[y] + "</color>" + "</size>";
}
for (int z = a.Length - 1; z >= 0; z--)
{
string t1 = content[x].Substring(0, a[z]);
string t2 = content[x].Substring(a[z] + 2, content[x].Length - a[z] - 2);
content[x] = string.Format("{0}{1}{2}", t1, b[z], t2);
}
}
}
private void ChangeText()
{
for (int x = 0; x < content.Count; x++)
{
var a = Regex.Matches(content[x], pattern).Cast<Match>().Select(m => m.Index).ToArray();
var b = Regex.Matches(content[x], pattern).Cast<Match>().Select(m => m.Value).ToArray();
string[] tmp = Regex.Matches(content[x], pattern).Cast<Match>().Select(m => m.Value).ToArray();
for (int y = 0; y < b.Length; y++)
{
tmp[y] = "<size="+size+">" + "<color=#"+colorNum+">" + tmp[y] + "</color>" + "</size>";
}
for (int z = a.Length - 1; z >= 0; z--)
{
var length = b[z].Length;
string t1 = content[x].Substring(0, a[z]);
string t2 = content[x].Substring(a[z] + length, content[x].Length - a[z] - length);
content[x] = string.Format("{0}{1}{2}", t1, tmp[z], t2);
}
}
}
fix bugs