Re: Changing URLs from Relative to Absolute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I was recently trying to write a script where a user copy and pastes their
HTML code to display something on a listings site and tried to find a way to
change the URL of an image from relative to absolute.
For example <img src="images/1.jpg"> becomes <img = src="
http://domain.com/images/1.jpg";>.
That is easy enough and I created a regexp, but I found that some people
call the img tag differently such as:
<img a="A photo" src="images/1.jpg">
Does anyone have experience of this? How can I create a regexp that will
find it in every case?

You could try this (from my rather poor memory):

/<img.*src="(.*)"/Uis

--
Richard Heyes
+44 (0)844 801 1072
http://www.websupportsolutions.co.uk

Knowledge Base and HelpDesk software
that can cut the cost of online support

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux