Re: [PHP] Re: Changing URLs from Relative to Absolute



Tom Chubb wrote:
Dear list,
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 may want to use DOM instead of Regex, since the order of the
attributes can be whatever the HTML coder felt like using that week...

Your regex is gonna get awfully complicated, since there could be all
manner of attributes, including browser-specific ones, or even garbage
ones, not to mention JavaScript...

--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?
.



Relevant Pages

  • Changing URLs from Relative to Absolute
    ... HTML code to display something on a listings site and tried to find a way to ... That is easy enough and I created a regexp, but I found that some people ...
    (php.general)
  • Re: Regex problem - please help.
    ... >> to the regulator a regex tester. ... but I spent lot of time playing with regex and I am ... >> I need to automatically extract HEADING and ... >> DESCRIPTION from the html code below? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Parse HTML
    ... RegEx Tutorial for VB: ... Veign's Resource Center ... "Madiya" wrote in message ... > I am getting the html code of a wab page in the variable in VB6. ...
    (microsoft.public.vb.general.discussion)
  • Re: Regex problem - please help.
    ... but I spent lot of time playing with regex and I am ... DESCRIPTION from the html code below? ... Can someone write REGEX command to get HEADING and DESCRIPTION. ...
    (microsoft.public.dotnet.languages.vb)
  • Regex problem - please help.
    ... but I spent lot of time playing with regex and I am ... DESCRIPTION from the html code below? ... Can someone write REGEX command to get HEADING and DESCRIPTION. ...
    (microsoft.public.dotnet.languages.vb)