Skip to content

Instantly share code, notes, and snippets.

@MoienTajik
Last active April 22, 2024 06:01
Show Gist options
  • Star 47 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save MoienTajik/acd3dbb359054bd22e06cc97281934eb to your computer and use it in GitHub Desktop.
Save MoienTajik/acd3dbb359054bd22e06cc97281934eb to your computer and use it in GitHub Desktop.
Regex For Iranian Mobile Phone Numbers

Regex For Iranian Phone Numbers

This regex supports all kinds of Iranian mobile phone numbers :

^(\+98|0)?9\d{9}$


Regex Visualized

Usage in JavaScript :

var regex = new RegExp('^(\\+98|0)?9\\d{9}$');
var result = regex.test('+989031234567');

console.log(result);

Regex Tester Demo

JSFiddle Demo

@AzMostafa
Copy link

AzMostafa commented Jan 10, 2024

hey guys
you can use this regex and enjoy:
/^((98|\+98|0098|0)*(9)[0-9]{9})+$/

look at this image:
image (1)

in this you can validation persian phone number like:

  1. with_out_zero: 9120000000
  2. with_zero: 09120000000
  3. with_zero_code: 00989120000000
  4. with_plus: +989120000000
  5. with_out_plus: 989120000000

also you can see this git repository and use other regex validating, filtering, sanitizing and finding Persian strings in laravel framework and kotlin.

@rezacloner1372
Copy link

^09(1[0-9] |2[0-2] |3[0-9] |9[0-9]) [0-9]{7}$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment