RegEx /href=.+"/g matching " repeatedly

Viewed 29

I'm trying to match a string using this RegEx: /href=.+"/g

var str= '<a href="https://www.url.com" target="_blank">';
console.log(str.match(/href=.+"/g));

however, I only want it to match this much: href="https://www.url.com"

Instead, it's matching this much: href="https://www.url.com" target="_blank"

1 Answers
.+

Matches 1 or more, for as many as possible, if you are trying to match until the nearest " ,then you will want as few as possible instead, so you will want

/href=.+?"/g
Related