0

This regex string is valid (see https://regex101.com/r/cL2wT3/2):

^(\+27|27|0)\s?(\d{2})[-\s]?(\d{3})[-\s]?(\d{4})$

But for some reason Angular 2 throws:

EXCEPTION: Error in ./App class App - inline template:5:8 caused by: nothing to repeat

You can see this in the console as soon as you start typing in the text box of this plnkr.

Why is this string not accepted by the validator?

Niel de Wet
  • 7,806
  • 9
  • 63
  • 100

1 Answers1

2

Escaping '\' is needed. So it should be

^(\\+27|27|0)\\s?(\\d{2})[-\\s]?(\\d{3})[-\\s]?(\\d{4})$
g.sui
  • 1,550
  • 3
  • 15
  • 20