我有一个这样的字符串:
$string = "some text
http://dvz.local/index/index/regionId/28
http://stuff.kiev.ua/roadmap_page.php http://192.168.3.192/roadmap_page.php
http://192.168.3.192/roadmap_page.php#qwe";
需要获取所有链接。
我试过这样:/http:\/\/(.*)[|\s]?/
返回:
array(2) {
[0] =>
array(3) {
[0] =>
string(42) "http://dvz.local/index/index/regionId/28\r\n"
[1] =>
string(77) "http://stuff.kiev.ua/roadmap_page.php http://192.168.3.192/roadmap_page.php\r\n"
[2] =>
string(41) "http://192.168.3.192/roadmap_page.php#qwe"
}
[1] =>
array(3) {
[0] =>
string(34) "dvz.local/index/index/regionId/28\r"
[1] =>
string(69) "stuff.kiev.ua/roadmap_page.php http://192.168.3.192/roadmap_page.php\r"
[2] =>
string(34) "192.168.3.192/roadmap_page.php#qwe"
}
}
编辑1:期望:
array(2) {
[0] =>
array(3) {
[0] =>
string(42) "http://dvz.local/index/index/regionId/28"
[1] =>
string(77) "http://stuff.kiev.ua/roadmap_page.php"
[2] =>
string(77) "http://192.168.3.192/roadmap_page.php"
[3] =>
string(41) "http://192.168.3.192/roadmap_page.php#qwe"
}
[1] =>
array(3) {
[0] =>
string(34) "dvz.local/index/index/regionId/28"
[1] =>
string(69) "stuff.kiev.ua/roadmap_page.php"
[2] =>
string(69) "192.168.3.192/roadmap_page.php"
[3] =>
string(34) "192.168.3.192/roadmap_page.php#qwe"
}
}