We have an XML schema that includes a RegEx to validate valid decimal / hex numeric input. This works with other RegEx enabled tools. It is designed to pass valid decimal numbers (e.g. 1234) and valid hex numbers with 0x prefix (e.g. 0x12AB):
<xs:simpletype name="hexdec">
<xs:restriction base="xs:string">
<xs:pattern value="\b(0x<span>[0-9a-zA-Z]</span>+|<span>[0-9]</span>+)\b">
</xs:pattern></xs:restriction>
</xs:simpletype>
When this schema is loaded into the XML Tools plug-in it reports that the RegEx is "not a valid regular expression).
XML Tools version: 2.4.9.2. Unicode
libXML 2.9.3
libXSTL 1.1.28
Same problem. Have in xsd:
<xs:simpletype name="ttime">
<xs:restriction base="xs:string">
<xs:pattern value="^(?:(?:(<span>[01]</span>?\d|2<span>[0-3]</span>):)?(<span>[0-5]</span>?\d):)?(<span>[0-5]</span>?\d)$">
</xs:pattern></xs:restriction>
</xs:simpletype>
When validate XML:
XML Tools plugin
Unable to parse schema file.
Parsing error at line 6634:
Element '{http://www.w3.org/2001/XMLSchema}pattern': The value '^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$' of the facet 'pattern' is not a valid regular expression.
Are you sure you reged is valid ? The regex of your first post looks quite strange... it contains <span> strings which has nothing to do with decimal parsing. Same with the regex of your second post. I guess it was transformed when posting.
Now if I focus on the regex
^(?:(?:([01]?\d|2[0-3]):)?([0-5]?\d):)?([0-5]?\d)$which is given in xmltools validation error: this regex is already wrong. I've tried to use it in a xsd file and even XMLSpy indicates it's wrong:Regexp valid, see examlpe:
http://regexr.com/3eq39
We use this regexp more 3 years
i thing intenal editor add 'span' in my exmaple.
normal code:
The "?:" pattern is a noncapturing group (http://speakingjs.com/es5/ch19.html). I don't think it exists in XSD (you only define pattern to match an expression, not to replace elements). "^" and "$" are not useful too.
Therefore, following pattern should do the same and should work:
yes, apply simple regex and error gone.
but, we need ?: to greate capture-group.
New regexp create 5 group, we need only 3.
I think the validator does not produce an error.
Same issue, following valid regex fails:
(?![cC][rR][mM]_)([A-Za-z0-9])+([_])+([A-Za-z0-9_])*another:
(\$webresource:|/)(.)+I have also come across the same with: