Regex too greedy?

Hi All,
I’m trying to do a regex on a string, here is an excerpt,

...},"end_address":"1901 SE Port St. Main  Blvd. Tampa, FL 34952","end_location" ...(data)... "end_location" ...(data)... "end_location"

This is the part that I want to target “end_address”:“1901 SE Port St. Main Blvd. Tampa, FL 34952”,“end_location” so I can replace the address.
This is my regex

string = string.replace(/end_address.*end_location/, 'end_address":"1895 main street North","end_location');

It works but the problem is that the regex spans all end_location (there should be many end_location) and wipes out a huge chunk of data, this leaves only one end_location.

I just need to match the first occurrence of end_location and not the last occurrence of end_location.


Isn’t that JSON? If so, why not just use json_decode?

You can use ? to denote a non-greedy match, such as .*?
Details about how it works are found at

@paul_wilkins Thank You, Thank You, Thank You, works a treat. Spent many hours on that.
@ScallioXTX I am using JSON.stringify(response); Its for the google maps response so I have a string that I need to work with.

Thanks to all.