C#如何提取字符串中最右边的几位数字?

2024-12-13 21:20:28
推荐回答(1个)
回答1:

string str = "如今 34 迈进 这 12,";
MatchCollection mc = Regex.Matches(str, @"\d+");
if (mc.Count > 0)
{
string lastnum = mc[mc.Count - 1].Value;//lastnum即最后的12
}