[英]Regular expressions preg_match with line breaks
I'm trying to match a string inside an HTML 我正在尝试匹配HTML中的字符串
for example I want to find the string inside <strong> string </strong>
例如,我想在<strong> string </strong>
找到字符串
what I'm doing is 我在做什么
preg_match_all('|\<strong\>(.*)\<\/strong>|',$html,$data);
echo $data[1][0];
it works when the string I want to search inside <strong>
is not a line break but if it has a line break, how can I do it? 当我要在<strong>
搜索的字符串不是换行符时,它可以工作,但是如果有换行符,我该怎么办?
not working example: 不工作的例子:
<strong>
line break string
</strong>
使用:
preg_match_all('/<strong>(.*)<\/strong>/s',$html,$data);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.