如何找到“<<>>”字符串中的单词

时间:2016-07-08 10:13:26

标签: php regex

我尝试了一些正则表达式模式,但仍无法找到解决方案。

我想从后面的字符串中获取<< >>个字词。

$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,">>")); 

如果有人知道请帮助我。

感谢。

1 个答案:

答案 0 :(得分:1)

此正则表达式将匹配<<>>

之间的字词
\<{2}([^\>]+)\>{2}

https://regex101.com/r/eX4xI4/1

preg_match_all("/\<{2}([^\>]+)\>{2}/", $string, $matches);
print_r( $matches );

https://eval.in/602428