You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Jean Croteau <cr...@cognicase.ca> on 2002/05/09 21:53:27 UTC
Reg expression
I'm trying to validate a date with the format yyyymmdd using an xml schema. So I'm using a regular expression that goes as follow :
^((0?[1-9]|[12][1-9]|3[01])\.(0?[13578]|1[02])\.20[0-9]{2}|(0?[1-9]|[12][1-9]|30)\.(0?[13456789]|1[012])\.20[0-9]{2}|(0?[1-9]|1[1-9]|2[0-8])\.(0?[123456789]|1[012])\.20[0-9]{2}|(0?[1-9]|[12][1-9])\.(0?[123456789]|1[012])\.20(00|04|08|12))$
Ok, so maybe it sucks, but I don't know of any other way to do it. Anyway, I get an error when I parse it using xerces. It says that 02.02.2002 is not valid. But it is valid, I tried this regular expression in a bunch of tools and it worked everywhere. Is this a xerces issue or is it a xml schema limitation ? Do xml schemas and/or xerces support POSIX regular expression syntax ?
Re: Reg expression
Posted by Jean Croteau <cr...@cognicase.ca>.
I have found my problem ... very stupid indeed !
Just remove the ^ and the $ and everything works ... go figure !
(20[0-9]{2}0?([13578]|1[02])(0?[1-9]|[12][1-9]|3[01])|20[0-9]{2}(0?[13456789]|1[012])(0?[1-9]|[12][1-9]|30)|20[0-9]{2}(0?[1-9]|1[012])(0?[1-9]|1[1-9]|2[0-8])|20(00|04|08)(0?[]|1[012])(0?[1-9]|[12][1-9]))
----- Original Message -----
From: Jean Croteau
To: xerces-j-user@xml.apache.org
Sent: Thursday, May 09, 2002 3:53 PM
Subject: Reg expression
I'm trying to validate a date with the format yyyymmdd using an xml schema. So I'm using a regular expression that goes as follow :
^((0?[1-9]|[12][1-9]|3[01])\.(0?[13578]|1[02])\.20[0-9]{2}|(0?[1-9]|[12][1-9]|30)\.(0?[13456789]|1[012])\.20[0-9]{2}|(0?[1-9]|1[1-9]|2[0-8])\.(0?[123456789]|1[012])\.20[0-9]{2}|(0?[1-9]|[12][1-9])\.(0?[123456789]|1[012])\.20(00|04|08|12))$
Ok, so maybe it sucks, but I don't know of any other way to do it. Anyway, I get an error when I parse it using xerces. It says that 02.02.2002 is not valid. But it is valid, I tried this regular expression in a bunch of tools and it worked everywhere. Is this a xerces issue or is it a xml schema limitation ? Do xml schemas and/or xerces support POSIX regular expression syntax ?