由网友(眉间朱砂)分享简介:我尝试提取与此源$ C $ c中的wan_ip的值(IP地址):怎么了?!我敢肯定的正则表达式模式是正确的。字符串输入= @VAR product_pic_fn =; VAR firmware_ver = '20 .02.024'; VAR wan_ip = '92 .75.120.206';!如果(parent...
我尝试提取与此源$ C $ c中的wan_ip的值(IP地址): 怎么了?!我敢肯定的正则表达式模式是正确的。
字符串输入= @VAR product_pic_fn =; VAR firmware_ver = '20 .02.024'; VAR wan_ip = '92 .75.120.206';!如果(parent.location.href =窗口。 location.href);
正则表达式IP =新的正则表达式(@[ B Ð{1,3} D {1,3} D {1,3} D {1,3} 湾。);
字符串[]结果= ip.Split(输入);
的foreach(在结果字符串BLA)
{
Console.WriteLine(BLA);
}
Console.Read();
解决方案
在 [
不应该在你的模式开始。此外,你可能想使用匹配(...)
。
尝试:
字符串输入= @VAR product_pic_fn =; VAR firmware_ver = '20 .02.024'; VAR wan_ip = '92 .75.120.206';!如果(parent.location.href =窗口。 location.href);
正则表达式IP =新的正则表达式(@ B Ð{1,3} D {1,3} D {1,3} D {1,3} 湾。);
MatchCollection结果= ip.Matches(输入);
Console.WriteLine(结果[0]);
I try to extract the value (IP Address) of the wan_ip with this sourcecode: Whats wrong?! I´m sure that the RegEx pattern is correct.
String input = @"var product_pic_fn=;var firmware_ver='20.02.024';var wan_ip='92.75.120.206';if (parent.location.href != window.location.href)";
Regex ip = new Regex(@"[bd{1,3}.d{1,3}.d{1,3}.d{1,3}b");
string[] result = ip.Split(input);
foreach (string bla in result)
{
Console.WriteLine(bla);
}
Console.Read();
解决方案
The [
shouldn't be at the start of your pattern. Also, you probably want to use Matches(...)
.
Try:
String input = @"var product_pic_fn=;var firmware_ver='20.02.024';var wan_ip='92.75.120.206';if (parent.location.href != window.location.href)";
Regex ip = new Regex(@"bd{1,3}.d{1,3}.d{1,3}.d{1,3}b");
MatchCollection result = ip.Matches(input);
Console.WriteLine(result[0]);
相关推荐
最新文章