Re: What does \\0 means?
| From: | John W. Holmes | Date: | Thu, 05 Aug 2004 14:03:39 +0000 |
| Subject: | Re: What does \\0 means? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-192860@lists.php.net to get a copy of this message | ||
From: "John Nichel" <john@kegworks.com>
>>On Thursday 05 August 2004 07:39, Jay offered up the following tid-bit of
>>information :
>> Found the following code in the PHP manual:
>> $text = "http://www.somelink.com";
>> echo(ereg_replace("[[:alpha:]]+://[^<>[:space:]]+[[:alnum:]/]",
>> "<a href=\"\\0\">\\0</a>", $text));
>>
>> What does \\0 means, i have seen this before with \\1 and \\2
>
> Well, I'm not much of a ereg guy...more preg, but if I had to take a
guess,
> the \\0 in ereg is like $1 in perl regular expressions. ie it's replacing
> the \\0 with the first match found in the expression. Run the
script...I'm
> betting it will out put...
>
> <a
> href="http://www.somelink.com">http://www.somelink.com</a>
>
> Course, if I'm wrong, someone on the list will be quick to lay the smack
> down on me, and you'll get the correct answer. ;)
oo.ooo... can I do it?? ;)
\\0 is actually the entire string that was matches. \\1 would be the first
parenthesized substring, \\2 the second, etc.
Don't worry, I had to look in the manual to be sure, too. :)
---John Holmes...