2 回答
TA贡献1831条经验 获得超9个赞
不是您真正要求的,但最终结果是。
using System;
using System.Collections.Generic;
namespace _52228638_ExtractAllPossibleMatches
{
class Program
{
static void Main(string[] args)
{
string inputStr = "asd123456789bbaasd";
foreach (string item in GetTheMatches(inputStr))
{
Console.WriteLine(item);
}
Console.ReadLine();
}
private static List<string> GetTheMatches(string inputStr)
{
List<string> retval = new List<string>();
int[] lengths = new int[] { 7, 8 };
for (int i = 0; i < lengths.Length; i++)
{
string tmp = new System.Text.RegularExpressions.Regex("(\\d{" + lengths[i] + ",})").Match(inputStr.ToString()).ToString();
while (tmp.Length >= lengths[i])
{
retval.Add(tmp.Substring(0, lengths[i]));
tmp = tmp.Remove(0, 1);
}
}
return retval;
}
}
}
- 2 回答
- 0 关注
- 219 浏览
添加回答
举报