You are here: Re: help understanding an ereg expression « PHP Programming Language « IT news, forums, messages
Re: help understanding an ereg expression

Posted by Jasen Betts on 02/10/06 22:30

On 2006-02-09, Jim Michaels <jmichae3@nospam.yahoo.com> wrote:
>
> "Palle Hansen" <palle@na.invalid> wrote in message
> news:43cf4b9b$0$84031$edfadb0f@dtext01.news.tele.dk...
>> yawnmoth wrote:
>>
>>> if (eregi("^[a-z0-9| |\,\-\+\.]+$",$string))
>>
>>> Why does $string = 'te\st' yield a match? The ereg expression doesn't
>>> have a \\ in it...
>>
>> To have this expression make sence to me, it should look like
>>
>> if (eregi("^[a-z0-9 ,+.-]+$",$string)){
>>
>> '-' should be the first og last character
>>
>> all the special characters looses their meaning in a character class.
>> so you acually have 4 maching backslashes in the expression
>
> nope. I just tried it. I've been able to escape things in RE char classes
> for a long time. otherwise, you couldn't include things like tabs \t,
> newline \n, return \r and other control characters,

those aren't escaped in the regular expression, they are escaped in the
string. The resular expression parser doesn't see the slashes associated
with those symbols, rather it sees the actual character.

> whitespace \s, word characters \w, decimal digits \d.

they don't work inside bracket expressions.

> We didn't get Perl's character classes
> like ::alpha:: (I don't think).

???



--

Bye.
Jasen

 

Navigation:

[Reply to this 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

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