> hi guys i now have a problem with urls i need to remove the quotes from both
> href="" and src=""
> so
> <a href="blah"> <img src=""> needs to be <a href=> <img src=> and i cant
> remove quotes from all string matches :|

Someone mentioned this already, but you should really know that if you
remove quotes from your HTML attributes, your HTML will no longer be
forward-compatible with XHTML, which you really should strive for.  What
reason would you have for removing the quotes?  There must be a better
workaround than removing them.

Regarding your question, it really depends on how you can operate on
your HTML.  Where is your HTML?  Is it in a database, string, etc?  Is
it all in one chunk?  That is, do you have stuff like this:

  <a href="some/url"><img src="some/image">This link has "quotes"</img></a>

that can't just have all quotes removed entirely from it?  If you really
need to remove quotes from attributes (and I don't think you do), and
all of your HTML is in one big string, you're looking at a regular
expression.  Read up on them here:


Yep, that's a lot of reading.  But you should learn about regular
expressions; they'll be useful all over the place.  If you happen to be
on a Linux/Unix/BSD/whatever machine that has man pages and perl
installed, check out `man perlre`.  Or read on-line here:


Some things to watch out for -- even if you do want to remove quotes
from your attributes, I'm 100% sure you don't want to remove from *all*
of them.  Like this:

  <img src="/some/image/" title="this is a pop-up description" />

Removing the quotes from the title attribute will likely break at least
some browsers, if not all.  So your regular expression needs to be able
to handle that gracefully.

Good luck!

[ joel boonstra | [EMAIL PROTECTED] ]

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to