Php 包含街道地址匹配的regexp achor href url

Php 包含街道地址匹配的regexp achor href url,php,regex,url,preg-match-all,street-address,Php,Regex,Url,Preg Match All,Street Address,我喜欢从html字符串中获取锚标记定义中的URL。html的结构相当好,但我试图收集的字符串包含GoogleMaps的地址,可以非常不同。我正在尝试使用preg_match_all获取所有匹配的URL <tr><td><a href="http://maps.google.com/maps?q=4165 E LIVE OAK AVE,">map</a></td></tr> <tr><td><a

我喜欢从html字符串中获取锚标记定义中的URL。html的结构相当好,但我试图收集的字符串包含GoogleMaps的地址,可以非常不同。我正在尝试使用preg_match_all获取所有匹配的URL

<tr><td><a href="http://maps.google.com/maps?q=4165 E LIVE OAK AVE,">map</a></td></tr>
<tr><td><a href="http://maps.google.com/maps?q=8000 SUNSET BLVD, LOS ANGELES,">map</a></td></tr>
<tr><td><a href="http://maps.google.com/maps?q=30600 THOUSAND OAKS BLVD, AGOURA,">map</a></td></tr>
<tr><td><a href="http://maps.google.com/maps?q=9090 19TH ST, ALTA LOMA,">map</a></td></tr>
<tr><td><a href="http://maps.google.com/maps?q=185 W ALTADENA DR, ALTADENA,">map</a></td></tr>
<tr><td><a href="http://maps.google.com/maps?q=620 E MOUNT CURVE AVE,">map</a></td></tr>

尝试以下正则表达式:

/http:\/\/maps.google.com\/maps\?q[^“]+(?=”)/
但是页面可能在您提供的HTML结构之外包含类似的URL,那么最好使用更复杂的regexp:


/(?谢谢你给我的是我需要缩短我以前试图使用的内容来获取所有URL。以下是我现在拥有的:
code
/\b(?:(?:https?;ftp):\/\/\www\)[^“]+(?=”/
code