I'm trying to extract an address from js code.
I have the following line extracted from raw javascript.
(new GLatLng(45.512242,-73.554009),'2860 Main Street S',icon_near)
I've made this Regex
"\(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)"
The problem is that I have multiple addresses together, and the regex match don't stop until the last ,icon_near\) is found.
I resolved my issue with this regex:
,
'(?<Address>.+?)'
(?=,icon_near\))
Try this instead:
\(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)
The single quotes were misplaced. Moreover, I remove one non needed single quote.
http://regex101.com/r/sX8dB2
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With