• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question: Pattern for string in XSD

 
Yongping Wang
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I want to use XSD to perform data validation. But now I just couldn't figure out a pattern for a string. The string format is like: XYZ. X consists of digits, its length must be 10-16, and is required. YZ (must be together) is optional, Y is fixed string like MAT, but Z is various. Z must be number between 0 and 23.
Thanks very much for your help.
Y.Ping
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The regex might look something like this:

(I haven't tested it so it might not even compile...)
 
Yongping Wang
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply.
Yes, the reg exp you provided works fine when the parenthesis removed from 1([0-9]) and 2...
I find another one to work for this case
\d{10,16}(MAT([0-9]|1[0-9]|2[0-3]))?
Thanks again
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic