You are here: Re: Windows/ Unix regular expression question « PHP Programming Language « IT news, forums, messages
Re: Windows/ Unix regular expression question

Posted by e_matthes on 05/30/07 01:30

On May 29, 3:32 pm, Alexey Kulentsov <criman...@crimaniak.com> wrote:
> e_matt...@hotmail.com wrote:
> > $acceptableTextRegExp = "/^[a-zA-Z0-9_\- ]\{$minLengthIn,
> > $maxLengthIn}/";
> .....
> > If I take out the \ before the open brace, both systems give me an
> > error about unmatched braces. Are escape characters handled
>
> PHP try to parse this: {$minLengthIn,$maxLengthIn} as one expression. {}
> used in PHP string as special symbols. You can use '-string to avoid
> such things:
>
> $acceptableTextRegExp = '/^[a-zA-Z0-9_\-
> ]{'.$minLengthIn.'.'.$maxLengthIn.'}/';


I can use the single-quote method to make my code work:
$regExp = '/^[a-zA-Z0-9_\- ]{' . "$minLength,$maxLength" . '}/';

I would still really like to know, however, why my local php
installation and the installation on my shared server interpret this
line differently:
$regExp = "/^[a-zA-Z0-9_\- ]\{$minLength,$maxLength}/";

My understanding is that the backslash tells php to escape the
following open brace. It seems to do that locally, but not on the
shared server. Any reason why the behavior is different on the two
systems?

 

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

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