You are here: Re: two kinds of regular expression « PHP Programming Language « IT news, forums, messages
Re: two kinds of regular expression

Posted by Andy Jeffries on 12/01/45 11:48

On Mon, 22 May 2006 14:38:52 -0700, John Dunlop wrote:
>> So it would seem that while [^0-9-] works in PHP/Perl, it's actually not
>> standard and I am correct to use [^0-9\-] in order to ensure maximum
>> compatibility with future version which may implement the standard more
>> strictly.
>
> I'd not say you're correct

OK, so ignoring the latter part about referring to standards, why am I not
correct?

> and I'd shy away from speaking about
> *the* "standard", whatever you mean by that. Where there's two kinds of
> regular expression, claiming that one is standard implies the other is
> not, forcing upon it gratuitous negative connotations. If you do feel the
> urge to think in terms of standard/non-standard, don't think of there
> being one standard and one non-standard but rather of there being two
> standards.

OK, considering the two main standards out there (PCRE and POSIX), both of
them suggest literal hyphens should be quoted within metcharacter classes.
The main book most people use to refer to Regular Expressions suggests the
same thing.

While I understand there's no one true standard for regexes, the nearest
things we have say it should be done one way, therefore although method B
also works, if it's not in any references it may be just an oversight that
will be removed in a latter revision of the code.

Cheers,


Andy


--
Andy Jeffries MBCS CITP ZCE | gPHPEdit Lead Developer
http://www.gphpedit.org | PHP editor for Gnome 2
http://www.andyjeffries.co.uk | Personal site and photos

 

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

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