eregi_replace: why doesn´t this work?

This is a discussion on eregi_replace: why doesn´t this work? within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi! I try to: function do_bug_link($in) { return eregi_replace("\!([0-9]+)","<a href='bug.php?op=...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-12-2003
Florian Leeber
 
Posts: n/a
Default eregi_replace: why doesn´t this work?

Hi!

I try to:

function do_bug_link($in)
{

return eregi_replace("\!([0-9]+)","<a
href='bug.php?op=show&bugid=\\1'>Bug \\1</a>",$in);
}

which should substitue all occurences in my $in like the following:

Blah text !123 blah text => Blah text <a
href='bug.php?op=show&bugid=123'>Bug 123</a> blah text

it works, partially....

output is:
Blah text <a href='bug.php?op=show&bugid=123'>Bug <a
href='/bug.php?op=show&bugid=123'>123</a></a>

why is this called recursively at the second \\1 ???


TIA,

F. Leeber


Reply With Quote
  #2 (permalink)  
Old 12-12-2003
Janwillem Borleffs
 
Posts: n/a
Default Re: eregi_replace: why doesn´t this work?


"Florian Leeber" <fleeber@ghl.at> schreef in bericht
news:vZpCb.27113$dt3.13388@news.chello.at...
>
> it works, partially....
>
> output is:
> Blah text <a href='bug.php?op=show&bugid=123'>Bug <a
> href='/bug.php?op=show&bugid=123'>123</a></a>
>
> why is this called recursively at the second \\1 ???
>


Not sure what you are passing the function as an argument, but the following
works for me:

function do_bug_link($in) {
return eregi_replace(
"\!([0-9]+)",
"<a href='bug.php?op=show&bugid=\\1'>Bug \\1</a>",
$in
);
}

echo do_bug_link("Blah text !123 blah text");


JW



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:41 PM.


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