Re: Regular Expression Challenge
| From: | Cameron Just | Date: | Tue, 26 Mar 2002 00:02:50 +0000 |
| Subject: | Re: Regular Expression Challenge | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-90117@lists.php.net to get a copy of this message | ||
No luck on any of those suggestions people but thanks anyway :(
I had a feeling it was a bit too complex for a regexp.
> Oh, I didnt read the bit at the bottom about the times appearing any
> number of times. Off the top of my head I think this should work...
>
> PREG:
>
> "/'([a-z]+)-([a-z]+)\s(?:([0-9]+(?::[0-9]+|))(?:,\s)?)*'/"
>
> --
> Matt
>
> ----- Original Message -----
> From: "Cameron Just" <c.just@phoenixdigital.com>
> To: <php-general@lists.php.net>
> Sent: Monday, March 25, 2002 6:15 AM
> Subject: [PHP] Regular Expression Challenge
>
>
>> Hi,
>>
>> I am trying to pull out the following information via a regular
> expression.
>>
>> The string I am searching on is 'wed-thurs 9:35, 14:56, 18:35'
>>
>> and I want it to retreive
>> wed
>> thurs
>> 9:35
>> 14:56
>> 18:35
>>
>> The regular expression I am using is
>> ([a-z]+)-([a-z]+) +([0-9]{1,2}:?[0-9]{0,2})[, ]*
>>
>> It seems to be grabbing the
>> wed
>> thurs
>> 9:35
>> but I can't seem to retrieve the rest of the times.
>>
>> Anyone have any ideas?
>>
>> BTW
>> There can be any number of 'times' in the string and also the 'times'
>> can be with or without the colon and the minutes, hence the
>> '}:?[0-9]{0,2}' part of the regexp.
>>
>>
>>
>>
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php