regex pattern to allow positive and negative integers

前端 未结 3 496
囚心锁ツ
囚心锁ツ 2020-12-19 05:15

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 val         


        
相关标签:
3条回答
  • 2020-12-19 05:34

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

    xs:pattern value="-?[0-9]{0,10}"
    
    0 讨论(0)
  • 2020-12-19 05:34

    Using the \d notation would make it even simpler:

    xs:pattern value="-?\d+"
    
    0 讨论(0)
  • 2020-12-19 05:38

    if you using python: example re.findall:

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

    *output: [negative integer, integer]

    0 讨论(0)
提交回复
热议问题