質問

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}"
役に立ちましたか?

解決

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

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

他のヒント

Using the \d notation would make it even simpler:

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

if you using python: example re.findall:

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

*output: [negative integer, integer]

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top