How can I match bangladeshi phone number using RegExp in javascript?

3673 views javascript

this following expression is working for any 11 digits phone number. But I want the first three digit to be specific operator code like (017, 016, 018, 019). And rest of the others can be any digits.


answered question

1 Answer


You may use an alternation here:


Code sample:

console.log(/^(01[6789])(\d{8})$/.test('01612345678')); // pass
console.log(/^(01[6789])(\d{8})$/.test('01912345678')); // pass
console.log(/^(01[6789])(\d{8})$/.test('12312345678')); // fail

posted this

Have an answer?


Please login first before posting an answer.