简体   繁体   中英

RegEx XSD not matching timestamp value

I'm using following pattern in xsd

(^$)|(^([1-2]\d{3}-([0]?[1-9]|1[0-2])-([0]?[1-9]|[1-2][0-9]|3[0-1]))[ |T]?((([0-1]?\d)|(2[0-3])):[0-5]\d)?(:[0-5]\d)?(\.\d{1,3})?$)

While testing, it is failing for value - '2013-01-01T23:59:46'

Could anyone please let me know what's wrong with the regex?

You're using ^ and $ to indicate anchors at the beginning and end of the string being matched. But XSD patterns are always anchored, and the characters ^ and $ just denote literal caret and dollar-sign respectively. Drop them and try again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM