c# - Why does this regex for iso8601 fail for UTC times specified with the Z suffix? -


here's regex:

^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[0-1]|0[1-9]|[1-2][0-9])t(2[0-3]|[0-1][0-9]):([0-5][0-9]):([0-5][0-9])(\\.[0-9]+)?(z|[+-](?:2[0-3]|[0-1][0-9]):[0-5][0-9])?$ 

the problem regex not matching strings z suffix. strings utc offset specified +0 or -0 work fine z not. what's wrong regex , how correct it?

"2012-06-21t19:32:26.2311892-04:00"  // match "2012-06-21t19:32:26.2311892-00:00"  // match "2012-06-21t19:32:26.2311892+00:00"  // match  "2012-06-21t19:32:26.2311892z" // not match 

you have \\. in expression should \.. corrected, example input z suffix matches.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -