Skip to content

Instantly share code, notes, and snippets.

View mghdmi's full-sized avatar
🏠
Working from home

mghdmi

🏠
Working from home
View GitHub Profile
@mghdmi
mghdmi / phoneNumberRegex.js
Created April 30, 2022 16:05
Iranian phone number regex (include persian digits)
// Validate numbers that starts with '+98' or '09' and 9 digits after.
// It also works with persian numbers.
const regex = /^((\+98|0|\+۹۸|۰)(9|۹)[0-9-۰-۹]{9})$/;
console.log(regex.test("+989121234567")); // true
console.log(regex.test("۰۹۱۲۱۲۳۴۵۶۷")); // true
console.log(regex.test("۰۹12۱۲34۵۶7")); // true
console.log(regex.test("+۹۸۹۱۲1234567")); // true
console.log(regex.test("+98912123456789")); // false