简体   繁体   中英

Regular expressions preg_match with line breaks

I'm trying to match a string inside an HTML

for example I want to find the string inside <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?

not working example:

<strong>
line break string
</strong>

使用:

preg_match_all('/<strong>(.*)<\/strong>/s',$html,$data);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM