You are here: Re: pattern match and extract problem « PHP Programming Language « IT news, forums, messages
Re: pattern match and extract problem

Posted by Jim Michaels on 02/17/06 10:30

"David Moore" <dave_m_moore@post2me.freeserve.co.uk> wrote in message
news:dsb232$ean$1@news7.svr.pol.co.uk...
> Hi All,
> I expect someone can crack this one in no time.
>
> Ok, what I'd like to do is to match a pattern in a string and extract a
> portion of it. For example if I had a string like:
>
> 'The store had apples(20) and pears(30)'
>
> how do I extract the '20' and '30'? ie. if the pattern is 'apples(??)',
> how do I expect the '??'.

sounds like you only want the numbers. easy.
preg_match_all("/\((\d\d)\)/", $string, $matches);
or if you want to handle any number of digits,
preg_match_all("/\((\d+)\)/", $string, $matches);

>
>
> Ta in advance,
> Dave
>
>

 

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

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