62,041
社区成员
发帖
与我相关
我的任务
分享
string tempStr = File.ReadAllText(@"C:\Documents and Settings\Administrator\桌面\Test.txt",Encoding.GetEncoding("GB2312"));
string pattern = @"(?is)(,[^,,]+){9}";
foreach (Match m in Regex.Matches(tempStr, pattern))
{
//循环输出
string value = m.Value;
}
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace ConsoleApplication16
{
class Program
{
static void Main(string[] args)
{
string str = @",K0033206,K0033797,K0040687,K0040690,K0041011,Z0050997,P0001113,P0001187,P0003789*,P0003874*,P0009381,P0010403,P0010635,S0000022,S0000023,S0000036,X0000236,X0000245,X0000326";
Regex rgx = new Regex(@"(?i),[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+,[^,]+");
foreach(Match m in rgx.Matches(str))
{
Console.WriteLine(m.Value);
}
}
}
/*
* ,K0033206,K0033797,K0040687,K0040690,K0041011,Z0050997,P0001113,P0001187,P000378
9*
,P0003874*,P0009381,P0010403,P0010635,S0000022,S0000023,S0000036,X0000236,X00002
45
请按任意键继续. . .
*/
}