Reputation: 23
I've got this regex /src='cid:(.*)'/Uims
and it works fine but only match element in single quote . What is the way to also allow result who match double quotes (like /src="cid:(.*)"/Uims
) but in a single regex?
Upvotes: 2
Views: 184
Reputation: 2306
/src=(["'])cid:(.*?)\1/Uims
Store the type of quotation as a back reference and refer to it where it should be closed.
Note that the back reference you are using will be located at \2 (or $2) instead of \1.
Oh, and you probably want to make the grouping lazy (non-greedy), so I added a ?
after .*
. See regular-expressions.info for more info.
Upvotes: 4