2016-07-08 15 views
-4

正規表現のパターンを試しましたが、まだ解決策が見つかっていません。"<< >>"文字列の単語を見つけるには

<< >>単語を次の文字列から取得します。

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

誰かが私を助けてください。

ありがとうございました。

+3

OK、との言葉を一致させるのだろうか? – Kasramvd

+0

あなたの質問をあなたのコードで更新し、出力に何が問題なのかを説明してください。 – Kasramvd

+0

私の解決策を見つけました... – user3374268

答えて

1

この正規表現は、あなたのコードがあり、それに伴う問題は何<<>>

\<{2}([^\>]+)\>{2} 

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

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

https://eval.in/602428

+0

おかげさまで働いています...... – user3374268

+0

いいえ汗: ')助けてよかったよ –

+0

それがうまくいくならば、答えを受け入れるべきです。 '<' and '>'はエスケープする必要はありません。 '​​)+)> {2} ' – chris85

関連する問題

 関連する問題