首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

字符串分割解决方法

2012-06-14 
字符串分割有个字符串A href../view/file.aspx?attachment1&name%u65B0%u5EFA%u6587%u672C%u6587

字符串分割
有个字符串
<A href="../view/file.aspx?attachment=1&amp;name=%u65B0%u5EFA%u6587%u672C%u6587%u6863.txt&amp;contentType=text/plain&amp;file=2012%5C6%5C3adc7681-b7fa-4e94-8199-742350026d58.txt" target=_blank><IMG border=0 src="../images/fileExt/txt.gif"> 新建文本文档.txt</A> (1k)<A href="../view/file.aspx?attachment=1&amp;name=%u65B0%u5EFA%u6587%u672C%u6587%u6863.txt&amp;contentType=text/plain&amp;file=2012%5C6%5C3adc7681-b7fa-4e94-8199-742350026d58.txt" target=_blank><IMG border=0 src="../images/fileExt/txt.gif"> 新建文本文档2.txt</A> (1k) 

内容是动态生成的
我想取"file="到"""之间的值
结果就是
2012%5C6%5C3adc7681-b7fa-4e94-8199-742350026d58.txt
2012%5C6%5C3adc7681-b7fa-4e94-8199-742350026d58.txt

MatchCollection mc = Regex.Matches(sPartPath, @"(?i)(?<=file=).*?(?='|;)", RegexOptions.IgnorePatternWhitespace);
我试了下 得不出想要的结果. 求帮助
有能解决的么?

[解决办法]
file=是不是固定的,关键结束部分不确定,一会又是单引号、双引号、又是分号,到底有哪些情况
试试
(?is)(?<=file=).*?(?=""|'|;)

热点排行