You are here: Re: Simple Regular Expression ? « All PHP « IT news, forums, messages
Re: Simple Regular Expression ?

Posted by McHenry on 10/10/34 11:51

"Rik" <luiheidsgoeroe@hotmail.com> wrote in message
news:d3c89$44a10ae8$8259c69c$25584@news1.tudelft.nl...
> McHenry wrote:
>> "Rik" <luiheidsgoeroe@hotmail.com> wrote in message
>> news:ab90a$449fde69$8259c69c$10096@news1.tudelft.nl...
>>> McHenry wrote:
>>>> Why could we not simply have used as this is what I tried and it
>>>> didn't work ?
>>>> <h3>.*?(?P<field2>[0-9\.,]*).*?</h3>
>>>
>>> 1. It matches a single dot or comma, not desired.
>>> 2. It matches 'nothing' (* = 0 or more)
>>>
>>> In <h3>.*?(?P<field2>[0-9]+[0-9\.,]*).*?</h3>, we use [0-9]+ to say:
>>> once you have found at least 1 number, and maybe more, capture all
>>> numbers, comma's and dot's.
>>
>> Thanks Rik, I understand the difference... wow are these things
>> normally easy to follow or always this heard ?
>
> YOu'll just have to get used to it, the more you use them, the easier they
> become. One reason I normally reply to regex questions is to sharpen my
> skills :-).
>
>> I have a regex, that performs three captures of three prices, it
>> works when all three are present and numeric however if one is
>> missing or listed as POA or similar then all three fail. Can this be
>> overcome or do I need three seperate preg_match statements ?
>>
>> Thanks in advance...
>
> With listed as 'POA' you mean it literally?
> If you're using the simple one:
>
> <h3>.*?(?:(?P<prices>(?:[0-9]+[0-9\.,]*)|POA).*?){1,3}</h3>
>
> Grtz,
> --
> Rik Wasmus
>
>

Rik, thanks as always. POA was simply an example it could be anything.
What I meant was if the one regex performs three caputres in the one
statement and one fails must all three fail or can the other two still
capture ?

 

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

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