0

I'd like to implement some client-side validation for a case-insensitive, blacklisting of variations on a word. For example, if the word in question is Dog, a user should not be able to enter any variation of it:

dog
doG
dOg
dOG
Dog
DoG
DOg
DOG

Was trying to experiment with a negative lookahead, i.e., ^(?!.*(?:dog|doG|dOg|dOG|Dog|DoG|DOg|DOG)) but that seems too verbose and not generic enough.

User 5842
  • 2,849
  • 7
  • 33
  • 51
  • 1
    Does this answer your question? [Regex: ignore case sensitivity](https://stackoverflow.com/questions/9655164/regex-ignore-case-sensitivity) – Tanner Jan 03 '20 at 15:26
  • Convert user entered value to lowercase and then compare with `dog` – anubhava Jan 03 '20 at 15:26
  • @Tanner, would I still need to include all variations of said word, hardcoded into the expression? – User 5842 Jan 03 '20 at 15:28
  • Nope, your regex should be /dog/i <- where i is the case-insensitive flag. that will cover doG, DOG, Dog, DoG and so on – Tanner Jan 03 '20 at 15:29

0 Answers0