0

I need to provide a list of regex for validating certain input, for example, the input must be within 4-8 characters:

(.){4,9}

But there's one requirement that the input cannot contain certain characters, I could figure out how I can check if the input does contain those characters:

[<=>]

But how do I make it so that it matches anything that DOESN'T contain those characters?

I thought about negating the set:

[^<=>]

But it matches as long as there's some character that's not in the set.

Thanks!

Update:

So here are a list of input and expected behaviours:

Input: OK Expected: failed to match (.){4,9}, length is less than 4

Input: 1+1=2 Expected: failed to match the regex that input cannot contain restricted characters, in this case, the equal sign =

Heuristic
  • 5,087
  • 9
  • 54
  • 94

0 Answers0