&BILLHEAD6025|20060509|20060509
13700000000|602502|20060511|1500|1
......
&BILLTAIL6025|16
&OUTHEAD6025|20060509|20060509
139000000|602507|20060509|5
......
&OUTTAIL6025|2
我有一段这样的内容,现在需要分开提取BILL项中内容和OUT项中的内容.BILL、OUT标签行的数字是会变动的,提取内容时不需要标签行内容.应该怎样取.在线等待........
13700000000|602502|20060511|1500|1
......
&BILLTAIL6025|16
&OUTHEAD6025|20060509|20060509
139000000|602507|20060509|5
......
&OUTTAIL6025|2
我有一段这样的内容,现在需要分开提取BILL项中内容和OUT项中的内容.BILL、OUT标签行的数字是会变动的,提取内容时不需要标签行内容.应该怎样取.在线等待........
public static string GetFirstStr(string strOriginal,string strSymbol)
{
int strPlace=strOriginal.IndexOf(strSymbol);
if (strPlace!=-1)
strOriginal=strOriginal.Substring(0,strPlace);
return strOriginal;
}
用这个一项一项拆
{
string s = "&(BILL|OUT)(?<Label>[^&]*)";
StringCollection lables = new StringCollection(); MatchCollection matches = Regex.Matches(text, s); foreach(Match match in matches)
{
lables.Add(match.Group("Label").Text);
}
return labels;
}
&BILLHEAD6025|20060509|20060509
13700000000|602502|20060511|1500|1
&BILLTAIL6025|16&OUTHEAD6025|20060509|20060509
139000000|602507|20060509|5&OUTTAIL6025|2表达式:[\&BILL][A-Z]{4}(?<mytag>[\d+\|\d*\n*\r*]*)结果:
6025|20060509|20060509
13700000000|602502|20060511|1500|16025|16表达式:[\&OUT][A-Z]{4}(?<mytag>[\d+\|\d*\n*\r*]*)结果:
6025|20060509|20060509
139000000|602507|20060509|56025|2测试器
http://birdshover.cnblogs.com/archive/2006/05/10/396844.html
(?<=OUT.*)[\S\s]*(?=OUT.*)