我想獲取給定HTML中的所有強標記。例如。我有以下HTML格式:獲取給定HTML中的所有強標記
<strong data-mention="2uwWMABSjBPWdAlSnglAlsY7A1cD1Q7EmHiM9wehxXyY99AQs6eC7rEt">Alex </strong> how are you? Is <strong data-mention="2uwWMABSjBPWdAlSnglAlsY7A1cD1Q7EmHiM9wehxXyY99AQs6eC7rEt">Matt</strong> coming today for a match?
我用:
preg_match_all('/<strong>(.*)<\/strong>/s',$string,$data);
但它沒有工作。我不知道RE。任何幫助,將不勝感激。謝謝!
通過使用preg_match_all('/<strong(.*)>(.*)<\/strong>/s',$string,$data);
我得到以下結果:
Array
(
[0] => Array
(
[0] => Alex ​ how are you? Is Matt
)
[1] => Array
(
[0] => data-mention="2uwWMABSjBPWdAlSnglAlsY7A1cD1Q7EmHiM9wehxXyY99AQs6eC7rEt">Alex ​ how are you? Is Array
(
[0] => Matt
)
)
這是不正確:( 我想這樣的輸出:
Array
(
[0] => Array
(
[0] => <strong data-mention="2uwWMABSjBPWdAlSnglAlsY7A1cD1Q7EmHiM9wehxXyY99AQs6eC7rEt">Alex </strong>
)
[1] => Array
(
[0] => <strong data-mention="2uwWMABSjBPWdAlSnglAlsY7A1cD1Q7EmHiM9wehxXyY99AQs6eC7rEt">Matt</strong>
)
)
預期產量是多少? – hwnd