1

Below is the latest version of the regular expression I am using and it is throwing the error "Invalid Regular Expression."

XSD: The regular expression '^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[^\da-zA-Z]).{10,15}$' failed to validate at location 4: This expression is not supported in the current option setting.

I'm getting this exception in my xsd file and I'm developing this xsd in message broker (IIB). Can anyone help to me how to resolve this ?

Paul R
  • 208,748
  • 37
  • 389
  • 560
  • Not an answer to your question, but your regex appears to have some typos, and I would write it as this: `^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.[^0-9a-zA-Z]).{10,15}$` – Tim Biegeleisen Nov 13 '18 at 11:05
  • 2
    May be your regex flavour doesn't support lookahead? – Toto Nov 13 '18 at 11:33

2 Answers2

0

Escape all = symbol:

As in change = to \=

Matnex Mix
  • 49
  • 8
0

It looks like you want to see if a string contains at least a capital case character, a small case character, a digit, a special character and if the string is between 10 to 15 characters long.

Like @Toto already commented, I think you flavour does not support lookahead. You can do it without (I borrowed and enhanced the code from here) by using capture groups and test them:

^
(?>                       #MAIN iteration (atomic only for efficiency)
    (?<upper>[A-Z])       #  an uppercase letter
  |                       # or
    (?<lower>[a-z])       #  a lowercase letter
  |                       # or
    (?<digit>[0-9])       #  a digit
  |                       # or
    (?<special>[^(0-9|a-z|A-Z)]) # a special
  |                      # or
    .                     #  anything else
){10,15}?                    #REPEATED 10 to 15 times
                          #
                          #CONDITIONS:
(?(upper)                 # 1. There must be at least 1 uppercase
    (?(lower)             #    2. If (1), there must be 1 lowercase
        (?(digit)         #       3. If (2), there must be 1 digit
            (?(special)   #           4. If (3) there must be 1 special   
              | (?!)      #          Else fail
            )             #
          | (?!)          #          Else fail
        )                 #
      | (?!)              #       Else fail
    )                     #
  | (?!)                  #    Else fail
) $                       #

You can test it here: regex101 example

AutomatedChaos
  • 7,267
  • 2
  • 27
  • 47