我是PHP正则表达式语法的新手。使用以下两行,我能够根据以下字符来表达网站:
’
newline
”
$html = @file_get_contents("http://news.yahoo.com");
$webwords = preg_split("/[:''n'"]+/", $html);
上面的代码只允许我根据单个字符来表达网站。你能告诉我如何使用word phrases
解析网站吗?例如,仅上面单个字符带有单词image_17
$webwords = preg_split("/[:''n'"]+ | (image_17) /", $html); ??
也许你需要类似的东西吗?
$html = 'xxx:yyyimage_17aaa:9999';
$webwords = preg_split("/([:''n'"]+|image_17)/", $html);
print_r($webwords);
和输出:
Array
(
[0] => xxx
[1] => yyy
[2] => aaa
[3] => 9999
)