2 回答

TA貢獻(xiàn)2016條經(jīng)驗(yàn) 獲得超9個(gè)贊

TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊
不是您真正要求的,但最終結(jié)果是。
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 關(guān)注
- 246 瀏覽
添加回答
舉報(bào)