Regular expression pattern to provide positive and negative integers

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

My current code only accepts positive integers.

xs:pattern value="[0-9]{0,10}"
+4
source share
3 answers

Assuming that only a negative sign is indicated before the number:

xs:pattern value="-?[0-9]{0,10}"
+7
source

Using notation \dwould make it even easier:

xs:pattern value="-?\d+"
+1
source

python: re.findall:

regex=re.findall(r'(-?[\d]+)',somestring)

* : [ , ]

-1

Source: https://habr.com/ru/post/1536609/


All Articles