*** John wrote/escribió (Fri, 05 Aug 2005 08:35:46 +0100):[color=blue]
> I would have expected this to match, am I right?
>
> if (eregi("a89", "a.[0-9]" ))
> {echo "<br>match" ;}
> else {echo "<br>no match";}[/color]
So your patter is 'a89'. It contains no special chars, so it's a literal.
And, definitively, it isn't contained in your string 'a.[0-9]'. It should
*not* match.
BTW, I'd say most PHP coders use Perl-comaptible regular expressions
(PCRE):
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
Alvaro G Vicario wrote:
[color=blue]
> *** John wrote/escribió (Fri, 05 Aug 2005 08:35:46 +0100):[color=green]
>> I would have expected this to match, am I right?
>>
>> if (eregi("a89", "a.[0-9]" ))
>> {echo "<br>match" ;}
>> else {echo "<br>no match";}[/color]
>
> http://www.php.net/eregi
>
> Description
> int eregi ( string pattern, string string [, array ®s] )
>
> So your patter is 'a89'. It contains no special chars, so it's a literal.
> And, definitively, it isn't contained in your string 'a.[0-9]'. It should
> *not* match.
>[/color]
Yup, I think you got the params the wrong way round A. RTFM. (and it works
when you put them the right way).
[color=blue]
> BTW, I'd say most PHP coders use Perl-comaptible regular expressions
> (PCRE):
>[/color]
What makes you say that J? I find it much more sensible to use the same
syntax that javascript supports (almost).
John wrote:
[color=blue]
>
> I am fairly new to php but I think I must be completely missing the
> poiny here (or going mad)
>
> I would have expected this to match, am I right?
>
> if (eregi("a89", "a.[0-9]" ))
> {echo "<br>match" ;}
> else {echo "<br>no match";}
>
> Thanks for any help
>
> John[/color]
Hi,
I think you should switch the arguments to eregi().
First pattern, than the string to unleash the pattern on.
Check www.php.net for the definition of the function.
*** Colin McKinnon wrote/escribió (Fri, 05 Aug 2005 09:51:14 +0100):[color=blue][color=green]
>> BTW, I'd say most PHP coders use Perl-comaptible regular expressions
>> (PCRE):[/color]
>
> What makes you say that J?[/color]
No stats, just an subjective impression. Most questions about regex I read
here seem to use preg_match() or preg_replace().
--
-- Álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don't e-mail me your questions, post them to the group
--
On Fri, 5 Aug 2005 11:26:56 +0200, Alvaro G Vicario wrote:[color=blue]
> No stats, just an subjective impression. Most questions about regex I read
> here seem to use preg_match() or preg_replace().[/color]
Also, the manual suggests it: "preg_match (), which uses a Perl-compatible
regular expression syntax, is often a faster alternative to ereg()."
--
On Fri, 05 Aug 2005 09:51:14 +0100, Colin McKinnon wrote:
[color=blue]
> What makes you say that J? I find it much more sensible to use the same
> syntax that javascript supports (almost).[/color]
Well I find it more sensible to use the same syntax Perl supports. So
there.
(Just pointing out the arbitrainess of your statement.)
Actually, though, my subjective assessment comes to the same conclusion as
Alvaro -- that preg_* is more commonly used than ereg*. If for no other
reason than the "faster alternative" reason stated on the PHP website.
On Fri, 05 Aug 2005 08:35:46 +0100, John <asdvfasd@asdfv rfg> wrote:
[color=blue]
>
>I am fairly new to php but I think I must be completely missing the
>poiny here (or going mad)[/color]
What can I say apart from DOLT.
Well for a start, sorry for missing this and thanks for your patience.
Belive it or not I did RTFM. Many times and looked on various sites to
get a different view. I can only assume I had a blockage such that
when it said 'pattern' I read it as the pattern to be tested. Heyho.
All I have to do now is work out the test I need.
Thanks again, all comments much appreciated.
--
John
PS Sorry for posting seperately as well. Shan't do that again, after
this
Comment