Boost logo

Boost Users :

From: Eric Niebler (eric_at_[hidden])
Date: 2006-04-12 13:32:20


Lynn Allan wrote:
>
> But, in example 2, seems like "year" should be repeat<1,4>, but:
> year= repeat<1,2> works:
>
> cregex date = (month= repeat<1,2>(_d)) // find the month ...
>>> (delim= (set= '/','-')) // followed by a delimiter ...
>>> (day= repeat<1,2>(_d)) >> delim // and a day followed by the same
>>> delimiter ...
>>> (year= repeat<1,2>(_d >> _d)); // and the year.
>
> actually, repeat<1,3> works for month, day, and year. Am I mixed up on
> what "repeat" means?

repeat<n,m>(X) means to match X between n and m times, inclusive. So
matching a month a day, you want repeat<1,2>(_d) to match 1 or 2 digit
characters, and to match a year, you want repeat<1,2>(_d >> _d) to match
two digits or four digits. Three digits isn't a common representation of
a year.

HTH,

-- 
Eric Niebler
Boost Consulting
www.boost-consulting.com

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net