Connecting Tech Pros Worldwide Help | Site Map

eregi_replace: why doesn´t this work?

  #1  
Old July 17th, 2005, 02:37 AM
Florian Leeber
Guest
 
Posts: 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
  #2  
Old July 17th, 2005, 02:37 AM
Pedro Graca
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing an array to a text file tnspc answers 9 February 10th, 2009 04:46 PM
Need help Making Script Work ojsimon answers 7 February 16th, 2008 01:50 AM
Any regex pro's out there? nel answers 5 June 6th, 2007 06:15 PM
=("|\')?([^ "\']*)("|\')?.*>([^<]*)</A>' lecichy answers 6 July 17th, 2005 01:43 AM