简体   繁体   English

RegEx XSD时间戳值不匹配

[英]RegEx XSD not matching timestamp value

I'm using following pattern in xsd 我在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' 在测试时,它的价值失败-'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. 但是XSD模式始终是固定的,字符^$仅分别表示文字插入符号和美元符号。 Drop them and try again. 放下它们,然后重试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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