By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,816 Members | 2,053 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,816 IT Pros & Developers. It's quick & easy.

eregi_replace: why doesn´t this work?

P: n/a
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
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Florian Leeber wrote:
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 ???

It works as expected for me.
$ php -v
PHP 4.3.3 (cli) (built: Nov 19 2003 23:12:29)
Copyright (c) 1997-2003 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2003 Zend Technologies

Anyway ... switch to preg_(); they are more powerfule and faster than
their ereg* counterparts.
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.