preg_replace href question

This is a discussion on preg_replace href question within the PHP General forums, part of the PHP Programming Forums category; Trying to rename all links like: <a name="link1" href="links.php" onmouseover="something&...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-10-2004
Jimmy Jim
 
Posts: n/a
Default preg_replace href question

Trying to rename all links like:

<a name="link1" href="links.php" onmouseover="something">

To be:

<a name="link1" href="index.php?filename=links.php"
onmouseover="something">

I am using --->

$contents = preg_replace("/href=\"(.*)\"/i",
"href=\"index.php?filename=\\1\"", $contents);

And it is coming back:

<a
href="index.php?filename=links.php"onmouseover="so mething">

Not sure why the end of line is after the "<a" and no space before the
"onmouseover". Can anyone help shed some light as to how to improve
this? Thank you,

JJ
Reply With Quote
  #2 (permalink)  
Old 02-11-2004
Jimmy Jim
 
Posts: n/a
Default Re: preg_replace href question

Not sure if I am posting in the wrong forum because I haven't heard
back from a few issues. If I am, would someone please let me know?
Thanks!

For an update to this problem, the only problem I have now is the
preg_replace seems to only be replacing the first link in my HTML
string. Not sure why. Is there something that I should be looking for
in the string that could be causing the replace to stop at that first
find?

Any help would be appreciated. Thanks!

JJ


jamesmgiordano@yahoo.com (Jimmy Jim) wrote in message news:<8e3d28ff.0402100836.df7129b@posting.google.c om>...
> Trying to rename all links like:
>
> <a name="link1" href="links.php" onmouseover="something">
>
> To be:
>
> <a name="link1" href="index.php?filename=links.php"
> onmouseover="something">
>
> I am using --->
>
> $contents = preg_replace("/href=\"(.*)\"/i",
> "href=\"index.php?filename=\\1\"", $contents);
>
> And it is coming back:
>
> <a
> href="index.php?filename=links.php"onmouseover="so mething">
>
> Not sure why the end of line is after the "<a" and no space before the
> "onmouseover". Can anyone help shed some light as to how to improve
> this? Thank you,
>
> JJ

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 10:05 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0