Boost logo

Boost Users :

Subject: Re: [Boost-users] regular expression problems
From: Green, Jason M NSWCDL, W33 (jason.m.green3_at_[hidden])
Date: 2009-04-23 14:28:19


That's correct. I hadn't gotten around to writing an update, but yes, my
problem was the 1-6 as opposed to 1,6.

Thanks

Jason

-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Anthony Foglia
Sent: Thursday, April 23, 2009 2:04 PM
To: boost-users_at_[hidden]
Subject: Re: [Boost-users] regular expression problems

John Maddock wrote:
>> I have a regex that validates a latitude format.
>>
>> These are the restrictions:
>>
>> Must have an N or S as first letter.
>>
>> It can be all values from 0.0 to 90.0
>>
>> My first shot at it confirmed format, but not data constraints:
>> "(N|S)\\d{2}\\.\\d{1,6} <file:///\\d%7b2%7d\d%7b1,6%7d> "
>>
>> But any attempts to limit the constraints caused an exception in
>> regex. Is
>> there something wrong w/ how I formatted this:
>> "(N|S)(9[0]\\.0{1-6}|[0-8]\\d\\.\\d{1-6}
>> <file:///\\.0%7b1-6%7d|[0-8]\d\d%7b1-6%7d> )"
>>
>>
>>
>> To me, it reads: 1st char must be N|S
>>
>> If second char is 9, the next chars must be 0.0 through 0.000000
>>
>> Else
>>
>> If char is 0-8, then the next just has to be digits [0-9].[0-9]{1-6}
>>
>> Can anyone tell me what I am doing wrong?
>
> There are no numeric constraints available in the regular expression
> language, and the {} operator are for constrained repeats with 1{1-6}
> not being a valid syntax.
>
> How about something like:
>
> (N|S)\\d(\\.\\d+|[1-8](\\.\\d+)?|9(\\.0+)?)?

I don't think that will match what he wants. It will match things like
"N99.0", which he prohibits.

It looks like the problem is "{1-6}" is invalid syntax. It should be
"{1,6}". In fact, that's what he wrote in his first shot, but not in
his second.

http://www.boost.org/doc/libs/1_38_0/libs/regex/doc/html/boost_regex/syntax/
perl_syntax.html

-- 
Anthony Foglia
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users

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