日期:2014-05-18  浏览次数:21058 次

怎么获取首尾固定的字符串
在一段文本里出现/plus/download.php?open=2&id=114&uhash=67aed3395bb5d02c3eb3980e"
这一段字符串 开头/plus/download.php?open这段和最后一个引号是固定的 剩下的都是不固定的
我怎么才能取到以/plus/download.php?open开头以"结尾的字符串

------解决方案--------------------
注意?要转义
C# code
string pattern1 = @"(?i)/plus/download.php\?open[^""\s]+?""";

------解决方案--------------------
Htmlstr.Text = strRegex;
应该是
Htmlstr.Text = m[0].Value;
或者类似的……
------解决方案--------------------
string str = "/plus/download.php?open=2&id=114&uhash=67aed3395bb5d02c3eb3980e\"";
var s = Regex.Match(str, @"(?is)/plus/download\.php\?open[^""]+(?="")").Value;
Response.Write(s);
***********************
结果
/plus/download.php?open=2&id=114&uhash=67aed3395bb5d02c3eb3980e 
***********************