读书人

正则表达式呀

发布时间: 2012-01-05 22:36:54 作者: rapoo

求一个正则表达式呀!
求一正则
http://222.54.214.227/ss/rf.php?site_id=15
用正则取=号后面的15
简单问题呀,算散分了。正则不会,不好意思呀!

[解决办法]
try

string yourStr = ...............;
Match m = Regex.Match(yourStr, @ "http://222\.54\.214\.227/ss/rf\.php\?site_id=(? <id> \d+) ", RegexOptions.IgnoreCase);
if (m.Success)
{
MessageBox.Show(m.Groups[ "id "].Value);
}
[解决办法]
Regex re = new Regex(@ "^.*site_id=(.*)$ ", RegexOptions.None);
MatchCollection mc = re.Matches( "http://222.54.214.227/ss/rf.php?site_id=15 ");
foreach (Match ma in mc)
{
MessageBox.Show(ma.Groups[1].Value);
}
[解决办法]
http.*?id=([\d]*)
[解决办法]
过客高手也

读书人网 >C#

热点推荐