PDA

View Full Version : regexp freaking me out



jerrel
21 Sep 2014, 11:35 AM
Hi Guys,
I most be tired, because i can't wrap my mind around regexp.

i need a regexp that only allows the following range of numbers.

71xxxxx - 75xxxxx

77xxxxx

81xxxxx - 89xxxxx

number length = 7

I would really appreciate it if you guys could guide me or help me out here.

evant
21 Sep 2014, 1:24 PM
Something like this:



var re = /^((7([1-5]|7))|8[1-9])\d{5}$/,
test = [],
suffix = '11111',
s;

for (i = 0; i < 99; ++i) {
s = i < 10 ? '0' + i : i;
s += suffix;

console.log(s, re.test(s));
}

jerrel
21 Sep 2014, 1:36 PM
Evant,

Many many tx it works great.