Reply to Re: regular expression help

Your name:

Reply:


Posted by www.douglassdavis.com on 09/15/05 10:39

Anno Siegel wrote:
> www.douglassdavis.com <doug@douglassdavis.com> wrote in comp.lang.perl.misc:
> > I am using the preg_match function (in PHP) that uses perl regular
> > expressions. Apparently I don't really understand regular expressions
> > though. Could some one explain this?
> >
> > If this is the regular expression
> >
> > /^\s*(\d+\.\d+)|(\.\d+)|(\d+)\s*$/
> >
> > How does this:
> >
> > 40:26:46.302N 79:56:55.903W
> >
> > match? I thought when I added the ^ and $ that meant it had to match
> > the whole thing? It seems to only be matching .302
>
> Concatenation binds tighter than alternation. So the first alternative
> is anchored to the left margin and the last one is anchored to the right
> margin. The middle one isn't anchored and matched what it can.
>

That makes sense. Thanks. This seems to work:

/^\s*((\d+\.\d+)|(\.\d+)|(\d+))\s*$/

[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

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