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

正则表达式呀

2012-01-05 
求一个正则表达式呀!求一正则http://222.54.214.227/ss/rf.php?site_id15用正则取号后面的15简单问题呀,

求一个正则表达式呀!
求一正则
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]*)
[解决办法]
过客高手也

热点排行