我尝试了一些正则表达式模式,但仍无法找到解决方案。
我想从后面的字符串中获取<< >>
个字词。
$string = "Yes! Bariatric surgery is covered under your plan. Click <<COMPANY>> here to contact a local surgeon and ask them to confirm your insurance benefits for free. See our <<INSURANCE>> page for coverage criteria or scroll down this page to learn more.";
$dash = substr($string,strpos($string,"<<"),strpos($string,">>"));
如果有人知道请帮助我。
感谢。
答案 0 :(得分:1)
此正则表达式将匹配<<
和>>
\<{2}([^\>]+)\>{2}
https://regex101.com/r/eX4xI4/1
preg_match_all("/\<{2}([^\>]+)\>{2}/", $string, $matches);
print_r( $matches );