Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating a regex to match date string

 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here are examples of my input string:

I want to validate this using XML Schema. So I trying to create a simpleType derived from xsd:String but I'm having some problems. Can anyone help? What is wrong with this simpleType? Why can't it meet my requirements stated above?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Instead of

[(Mon)(Tues)(Wednes)(Thurs)(Fri)(Satur)(Sun)]

try

(Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)

And similarly for other elements you wish to join with "or". The only time you should use braces [] or "or" something is when you're talking about single characters. E.g. [123] means 1 or 2 or 3, fine. But the whole expression is just one character (which can be one of thee possibilities. If you want to "or" things that are longer than one character, you need | instead.
 
Pho Tek
Ranch Hand
Posts: 782
Chrome Python Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Jim,

Thanks. It's working fine now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic