我有这样的文字,我喜欢来检测住址IP与preg_match
正则表达式PHP不工作
Nmap scan report for pc39.home (192.168.1.15)
你会发现那里,我已经使用正则表达式,但它不能正常工作的retrun为0
$regex=preg_match('/^\(([\d.]+)\)$/', $scan, $out);
预先感谢您。
我有这样的文字,我喜欢来检测住址IP与preg_match
正则表达式PHP不工作
Nmap scan report for pc39.home (192.168.1.15)
你会发现那里,我已经使用正则表达式,但它不能正常工作的retrun为0
$regex=preg_match('/^\(([\d.]+)\)$/', $scan, $out);
预先感谢您。
你的正则表达式是错误的:
^\(([\d.]+)\)$
^ here ^
您具有约束力的结果开始和输入结束,所以如果有只有括号,没有别的之间的IP地址,将只匹配。
你只需要:
\(([\d.]+)\)
您可以检查它regex101。
谢谢$重新=“/ \\(([\ \ d] +)\\)/“。 \t $ regex = preg_match($ re,$ scan,$ out); –
你在这里问同样的问题:http://stackoverflow.com/questions/37294578/regular-expression-to-match-ip-addresses – Andreas