Link to home
Start Free TrialLog in
Avatar of peter1950
peter1950

asked on

Validate time / date with regular expression

Hi

I must convert NMEA UTC time and date to VB.NET DateTime variable.

I want validate NMEA Time (for example "182635.000" = 6:26:35 PM / 18:26:35; 000 are milliseconds that i don't use in my time variable but i want use to validation) with regular expression, but It's to difficult. Can anyone help me ?

And for validating a UTC date "181007" (18th October 2007)

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of peter1950
peter1950

ASKER

Thanks.

And if I want to test that the lenght Is exactly 10 chars and that the first 6 chars are digit ?
\d{6}\.\d{3}

Bob
And if I want to use

([0-2][0-3]|[0-1][0-9])[0-5][0-9][0-5][0-9]\.\d{3}

and

\d{6}\.\d{3} together ?

I try
([0-2][0-3]|[0-1][0-9])[0-5][0-9][0-5][0-9]\d{6}\.\d{3} but it doesn't work.
Excuse me.

With

([0-2][0-3]|[0-1][0-9])[0-5][0-9][0-5][0-9]

obtain the same result as

\d{6}.

And for validating a date ?
I don't understand.  Are you looking to combine those two validation expressions into a single one?

Bob