Php Preg匹配正则表达式
preg_match_all要获取此字符串的内容部分,表达式将是什么:Php Preg匹配正则表达式,php,regex,Php,Regex,preg_match_all要获取此字符串的内容部分,表达式将是什么: < meta itemprop="url" content="whatever content is here" > 到目前为止,我已经尝试: preg_match_all('| < meta itemprop=/"url/" content=/"(.*?)/" > |',$input,$outputArray); preg_match_all(“|),$input,$outputArray)
< meta itemprop="url" content="whatever content is here" >
到目前为止,我已经尝试:
preg_match_all('| < meta itemprop=/"url/" content=/"(.*?)/" > |',$input,$outputArray);
preg_match_all(“|),$input,$outputArray);
试试这个表达式:
<?php
$input = '< meta itemprop="url" content="whatever content is here" >';
preg_match_all('/content="(.*?)"/',$input,$outputArray);
print_r($outputArray);
?>
编辑
如果只想获取itemprop=“url”
的内容,请将regex修改为
preg_match_all('/itemprop="url".*content="(.*?)"/',$input,$outputArray);
preg_match_all('/itemprop="url".*content="(.*?)"/',$input,$outputArray);