You are here: Re: [PHP] preg_match help please « PHP « IT news, forums, messages
Re: [PHP] preg_match help please

Posted by Steve Turnbull on 09/08/05 18:51

On Thu, 08 Sep 2005 16:36:36 +0100, Steve Turnbull wrote:

> On Thu, 08 Sep 2005 09:15:03 +0100, Steve Turnbull wrote:
>
>> On Thu, 08 Sep 2005 19:27:49 +1200, Jasper Bryant-Greene wrote:
>>
>>> Steve Turnbull wrote:
>>>> I am trying to find a regular expression to match a variable, what I think
>>>> should work (but doesn't) is;
>>>>
>>>> preg_match ('^/[\w],[\w],/', $variable)
>>>>
>>>> The $variable MUST contain an alpha-numeric string, followed by a comma,
>>>> followed by another alpha-numeric string, followed by another comma
>>>> followed by (but doesn't have to!!) another alpha-numeric string followed
>>>> by nothing.
>>>>
>>>> I realise my regex above doesn't allow for the last 'followed by nothing',
>>>> but to me it looks like it should match the first part of the string up to
>>>> the last comma?
>>>
>>> Something like
>>>
>>> '/^\w+,\w+,\w*$/'
>>>
>>> maybe? (untested)
>>>
>>> http://php.net/reference.pcre.pattern.syntax
>>
>> Thats got me a lot further - thanks
>>
>> I reduced it slightly to '/^\w+,\w+,' because at the end there is the
>> possibility of an alpha-numeric character(s) OR nothing at all with the
>> exception of a possible line break (note possible)
>>
>> It's the 'possibly nothing at all' which I am slightly stuck on
>>
>> Thanks
>> Steve
>
>
> One more thing (I have tried researching myself and reading the o'rielly
> book, but I need fairly swift solutions)...
>
> How would I check for this scenario;
>
> Two commas, which MAY have, but don't always have a value between, but
> the commas must ALWAYS be there - i.e.
>
> var1,var2,var3
> var1,var2,
> var1,,
>
No matter now - sorted. I hadn't read the final reply before I posted this
one

Thanks again

Steve

> Cheers
> Steve

 

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

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