Reply to Re: help understanding an ereg expression

Your name:

Reply:


Posted by Jim Michaels on 02/15/06 23:35

"Jim Michaels" <jmichae3@nospam.yahoo.com> wrote in message
news:abGdnauMypBKNnbeRVn-vw@comcast.com...
>
>
> "yawnmoth" <terra1024@yahoo.com> wrote in message
> news:1137648980.011472.98440@f14g2000cwb.googlegroups.com...
>> Say I have the following script:
>>
>> <?
>> $string = 'test';
>> if (eregi("^[a-z0-9| |\,\-\+\.]+$",$string))
>
> ^ means starting from the beginning of the line
> [] means match one character in the set between the brackets.
> + after the [] means match 1 or more of those.
> $ means must hit the end of the line.
>
>> {
>> echo 'matches!';
>> }
>> else
>> {
>> echo 'no match';
>> }
>> ?>
>>
>> Why does $string = 'te\st' yield a match? The ereg expression doesn't
>> have a \\ in it...
>>
>> Also, what does | | do? Normally, it'd mean 'or', but inside of []'s?
>> And two of them?
>>
>
>

after my tests, this ereg is clearly wasn't written for any PHP function.
were it written for preg_match, it is missing // around the ends and the
case insensitivity using \w instead of a-z. it's not writen for ereg
because of the |'s and the \'s. Only 1 should be necessary, but clearly they
put two in because they thought it had some special meaning. I don't
remember what significance (if any) | had in a Perl RE (which preg_match
series of functions is compatible with). This could have maybe been a
bad(?) Perl RE port-attempt to PHP.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация