-2

In Angular 8 I need to validate if a string is equal to yes allowing:

  1. Spaces, and only spaces, before and after.

  2. Case insensitive so Yes, YES, ... would be allowed.

I tried the following regex Regexr:

^(?i)yes$

But I get an error:

(?i) is not allowed in Javascript

And I am not allowing spaces between and after.

Miguel Moura
  • 36,732
  • 85
  • 259
  • 481

1 Answers1

0

The pattern you are looking for is / *yes */i.

Robo Robok
  • 21,132
  • 17
  • 68
  • 126