Why the following JavaScript regex could not work?

s='<img src="http://25.media.tumblr.com/xxxxx/tumblr_xxx_1280.jpg">'
p=/(?=<img src=")http:\/\/\d*\.media\.tumblr\.com\/\w*\/?tumblr_\w*_\d{3,4}\.\w{3,3}(?=")/g
s.match(p) # return null

However, the following works:

p=/(<img src=")http:\/\/\d*\.media\.tumblr\.com\/\w*\/?tumblr_\w*_\d{3,4}\.\w{3,3}(?=")/g

?= : Positive lookahead. Matches a group after your main expression without including it in the result.

You are looking for a positive lookbehind, as you are trying to match something before your main expression, if you are trying to extract the URL only.

p=/(?<=img src=....
     ^ positive look-behind

EDIT:

They aren't supported in JavaScript(as the comments indicate), so you'd have to resort to trickery.

However, if you are trying to extract the URL, it might be easier to split it over 2 steps, getting the entire match and then removing the <img src=... part.

Your first regex cannot match because it uses a zero-width look-ahead that contradicts the pattern that follows it.

A regex cannot match "<img src=" and in the same place in the string also match e.g. "http://25".