lfalanga
4/22/2016 - 3:08 PM

RegEx: Examples

RegEx: Examples

// 6 fixed numeric characters
var regEx = /^\d{6}$/;
if (!regEx.test(testingString)) {
  // Do something
}

// 17 to 18 numeric characters staring with "89"
var regEx = /^89\d{17,18}$/;
if (!regEx.test(testingString)) {
  // Do something
}

// 1 to 10 numeric characters
var regEx = /^[0-9]{1,10}$/
if (!regEx.test(testingString)) {
  // Do something
}