简体   繁体   中英

how to write regex for number not starting with 11 in WSDL

I need a regular expression for WSDL, in which a number should not start with 11 . I'm using the following pattern but it is not working. The number is 4 digit and it should not start with 11.

<xsd:pattern value="(?!11)[0-9]{2}[0-9]{2}" />

Thanks in advance.

How about the following regex:

((1[02-9])|([02-9]1)|([02-9][02-9]))[0-9][0-9]
  ^^^^^^^   ^^^^^^^   ^^^^^^^^^^^^  ^^^^^^^^^^
  AAAAAAA   BBBBBBB   CCCCCCCCCCCC  DDDDDDDDDD

What the partial expressions do:

  • AAA finds all two digit numbers starting with 1 and not having 1 as the second digit
  • BBB finds all two digit numbers ending with 1 and not having 1 as the first digit
  • CCC finds all two digit numbers not containing the digit 1 at all
  • DDD adds two more digits 0..9 to make it a four digit number

The pipe signs | between the expressions AAA and BBB and CCC function as a logical OR.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM