How to obtain the video address and title in the php regular expression? for example, the article content contains the following link address:
This is an mkv video test.
This is a mov video test.
This is a swf video test
This is an avi video test.
This is an mp4 video test.
I want to obtain the following result through regular expression:
Array (
Url => mkv_test.mkv,
Title => This is an mkv video test.
)
Array (
Url => mov_test.mov,
Title => This is a mov video test.
)
Array (
Url => swf_test.swf,
Title => This is a swf video test.
)
......
How can I write regular expressions?
Reply to discussion (solution)
$ S = <TXT this is mkv video test this is mov video test this is swf video test this is avi video test this is mp4 video test TXT; preg_match_all ('/href = "(. +) "> (. +)$ V) {$ arr [] = array ('URL' => $ v, 'title' => $ m [2] [$ k]);} print_r ($ arr );
$ Str = <mark: this is an mkv video test. this is a mov video test. this is a swf video test. this is an avi video test. this is an mp4 video test mark. $ rule = '#\(.*?) \ <\/A> # '; preg_match_all ($ rule, $ str, $ arr); $ item = array (); foreach ($ arr [1] as $ k => $ v) {$ item [] = array ('URL' => $ v, 'title' => $ arr [2] [$ k]);} print_r ($ item );
Array ([0] => Array ([url] => mkv_test.mkv [title] => This is an mkv video test) [1] => Array ([url] => mov_test.mov [title] => This is a mov video test) [2] => Array ([url] => swf_test.swf [title] => This is a swf video test) [3] => Array ([url] => avi_test.avi [title] => This is an avi video test) [4] => Array ([url] => mp4_test.mp4 [title] => This is an mp4 video test ))
$ Str = <mark: this is an mkv video test. this is a mov video test. this is a swf video test. this is an avi video test. this is an mp4 video test mark. $ rule = '#\(.*?) \ <\/A> # '; preg_match_all ($ rule, $ str, $ arr); $ item = array (); foreach ($ arr [1] as $ k => $ v) {$ item [] = array ('URL' => $ v, 'title' => $ arr [2] [$ k]);} print_r ($ item );
Array ([0] => Array ([url] => mkv_test.mkv [title] => This is an mkv video test) [1] => Array ([url] => mov_test.mov [title] => This is a mov video test) [2] => Array ([url] => swf_test.swf [title] => This is a swf video test) [3] => Array ([url] => avi_test.avi [title] => This is an avi video test) [4] => Array ([url] => mp4_test.mp4 [title] => This is an mp4 video test ))
Thank you for your answers.
Thank you for your answers.