On Sat, Feb 14, 2004 at 12:50:55AM -0500, Adam Bregenzer wrote:
> As far as I could tell the regexp I posted was the only one to use a
> subpattern to match the first quote type used and then re-apply that
> after matching the file name:
> '/<img\s+src=([\'"])([^\1]+)\1\s*\/?\s*>/i'
>
> I am a bit of a regular expression fan and I would be interested in
> seeing another way to match without using subpatterns. What was Joel's
> regexp again?
You're right that my regexp[0] didn't require the quote marks to match each
other. Depending on how strict/lax you want to be, that might be a
feature or a bug ;)
As to doing it without subpatterns... this seems to get there:
'#<img\s+src=((\'[^\']*\')|("[^"]*"))\s*/?\s*>#i'
but isn't as elegant or extensible as yours, although it does allow for
<img src=""> (that is, an empty src attribute). Also, it's less clear
where your matches are in mine, since there are so many parens.
IOW, Adam's is better ;)
[0]: The one I posted was:
'/<img src=["\'](.*?)\.(.*?)["\']>/i'
which didn't require quotes to match each other, didn't allow for
arbitrary whitespace, and didn't allow for XHTML-style tag closing.
--
[ joel boonstra | gospelcom.net ]
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php