Connecting Tech Pros Worldwide Help | Site Map

eregi_replace: why doesn´t this work?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 01:37 AM
Florian Leeber
Guest
 
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

  #2  
Old July 17th, 2005, 01:37 AM
Pedro Graca
Guest
 
Posts: n/a
Default Re: eregi_replace: why doesn´t this work?

Florian Leeber wrote:[color=blue]
> 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 ???[/color]


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 =--
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.