我试着去寻找一个字符串三个数据,他们是:正则表达式,PHP,“AND”
first name, space ,last name (?=[A-Z][a-z]+\s[A-Z][a-z]+)
//AND
first name ,space ,last name ,and suffix (?=[A-Z][a-z]+\s[A-Z][a-z]+\s[A-Z][a-z]+)
//AND,
age (?=[0-9]{2})
从几个教程我已经看到了它看来,这三种模式:
(?=[A-Z][a-z]+\s[A-Z][a-z]+)(?=[A-Z][a-z]+\s[A-Z][a-z]+\s[A-Z][a-z]+)(?=[0-9]{2})
在一起,应该是我的解决方案,但它不工作....任何建议....(它的一个PHP脚本和IM使用preg_match_all)
我的脚本:
$content = file_get_contents('http://www.somesite.com');
$pattern = '/(?=[A-Z][a-z]+\s[A-Z][a-z]+)(?=[A-Z][a-z]+\s[A-Z][a-z]+\s[A-Z][a-z]+)(?=[0-9]{2}) /';
if(preg_match_all($pattern,$content,$matches))
{
// has the pattern, do something
//$matches has all the matches from preg_match
}
请发布您的脚本 –
字符串“its [sic] not working”不是PHP中的内置错误消息。 – 2013-07-30 04:13:10
我发布了我的脚本...我在错误控制台中没有收到错误... – codenamejupiterx