0
  1. XXX-XXX-XXXX
  2. XXXXXXXXXX

I want to use a regular expression of the format. I tried as shown below, and an error occurs. How do I fix it?


  1. sample var regExp = / ^ 01 ([0 | 1 | 6 | 7 | 8 | 9]?) - ([0-9] {3}) - ([0-9] {4}) $ /??;
  2. sample var regExp = / ^ 01 ([0 | 1 | 6 | 7 | 8 | 9]?) ([0-9] {3}) ([0-9] {4}) $ /??;
min_jeong
  • 23
  • 7
  • Are there spaces in the telephone numbers you're trying to match? No. So first remove every space in your regular expressions. – tcooc Oct 20 '16 at 17:42
  • seriously? This question must have been asked over 10000 times already on the interwebs. – theonlygusti Oct 20 '16 at 17:48

1 Answers1

0

sample 1

var regExp = /^01([016789]?)-([0-9]{3})-([0-9]{4})$/;

sample 2

var regExp = /^01([016789]?)[0-9]{3}[0-9]{4}$/;

just make sure you don't have spaces and remove | from [0|1|6|7|8|9]

TornadoHell
  • 141
  • 6