You are here: Re: Problem with regular expression and preg_match « PHP Programming Language « IT news, forums, messages
Re: Problem with regular expression and preg_match

Posted by Scott on 03/21/06 22:46

On Tue, 2006-03-21 at 20:39 +0000, splodge wrote:
> I have a simple regular expression:
>
> [0-9]{1,5}x[0-9]{1,5}
>
> Which is designed to detect the width and height of an image from a
> string, as in:
>
> foo 100x100 bar
>
> However, when I run this with preg_match I get an unknown modifier
> error, pointing to { . Could someone please explain what I am doing
> wrong and how to make this work.
>
> preg_match("[0-9]{1,5}x[0-9]{1,5}", $output, $widthHeight);
>
> $output is the string containing the width height values
> $widthHeight is the returning array.
> Many thanks.
>
> P.s. Maximum image size is 99999x99999

Try enclosing your expression with / /.
preg_match("/[0-9]{1,5}x[0-9]{1,5}/", $output, $widthHeight);

 

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

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