Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

regex pattern to allow positive and negative integers

Tags:

regex

xsd

I am trying to find regex pattern in XSD that allow both positive and negative integers

My current code allows only positive integers.

xs:pattern value="[0-9]{0,10}"
like image 698
user3425746 Avatar asked Apr 15 '14 14:04

user3425746


2 Answers

Using the \d notation would make it even simpler:

xs:pattern value="-?\d+"
like image 169
Adam Hunyadi Avatar answered Sep 28 '22 10:09

Adam Hunyadi


Assuming you only mention an optional negative sign in front of the number:

xs:pattern value="-?[0-9]{0,10}"
like image 40
Felix Yan Avatar answered Sep 28 '22 08:09

Felix Yan