Forum Moderators: coopster
I have been trying to create a regexp pattern so I can get the src= part of any image tag. This is what I have come up with so far:
$matchSrc = '/<\s*IMG\s*\S*src=\s*[\"¦\'](.*?)\s*[\"¦\']/i';
This works fine, but how can I modify this so to collect images that aren't in "" or '' (I know they SHOULD be surround by quotes, but I'm finding a lot that aren't).
Thank you
Chris
"/\< *[Ii][Mm][Gg] *[Ss][Rr][Cc]= *[\"¦\']{0,1}([^\"\'\>]*)/"
You can use the pattern modifier "i" so that the regex matches are not case sensitive, so you could change it to
"/\< *[img] *[src]= *[\"\']{0,1}([^\"\'\>]*)/i"
You should maybe make provision for erroneous spaces in the tag, AFAIK spaces can appear in parts of the regex and is still standard HTML.