|
Posted by Rik on 08/23/06 14:33
Mike Collins wrote:
> '/<img[^>]*?(alt\s*=\s*[\'"][^\'"]*[\'"])[^>]+>.*/i',
> '$1', $row['text']) . ' (<b>IMG ALT</b>)';
> }
> I do believe the regex looks pretty good. It accounts for single and
> double quotes and spaces around the equals. Any other observations?
I'm curious what the reason for the last .* is. You want to replace
everything up to the end of the line?
Also, once it's matched either a single or double quote, best to stick with
it offcourse, so alt='15" monitor' works:
'/<img #opening tag
[^>]*? #random chars within tag up until next match
(alt\s*=\s* #start of alt attribute
(\'|") #get the quote
([^\2]*) #everything except the used quote
\2) #endquote, end of alt-attribute
[^>]* #allow for excess chars within the tag (why even
match them?)
>.*/ix',
Grtz,
--
Rik Wasmus
Navigation:
[Reply to this message]
|