我正在尝试从js代码中提取地址。
我从原始javascript中提取了以下行。
(new GLatLng(45.512242,-73.554009),'2860 Main Street S',icon_near)
我做了这个正则表达式
"\(new\sGLatLng\( #Start of the match
(?<Lat>\-?\d{1,3}.\d+) #Latitude
,
(?<Long>\-?\d{1,3}.\d+)\) #Longitude
,'
(?<Address>.+) #The address
(?=',icon_near\)) #Positive LookAhead. The regex end just before ',icon_near)"
问题是我在一起有多个地址,并且正则表达式匹配直到,icon_near\)
找到最后一个才停止。
我用此正则表达式解决了我的问题:
,
'(?<Address>.+?)'
(?=,icon_near\))
尝试以下方法:
\(new\sGLatLng\( #Start of the match
(?<Lat>\-?\d{1,3}.\d+) #Latitude
,
(?<Long>\-?\d{1,3}.\d+)\) #Longitude
,
'(?<Address>.+)' #The address
(?=,icon_near\)) #Positive LookAhead. The regex end just before ',icon_near)
单引号放错了位置。此外,我删除了一个不需要的单引号。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句