-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
  • 32,822
  • 74
  • 219
  • 400

1 Answers1

0

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

Robo Robok
  • 18,202
  • 14
  • 57
  • 101