Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

regular expression for indian mobile number

Use the following regex

^(+91[-s]?)?[0]?(91)?[789]d{9}$
This will support the following formats:

8880344456
+918880344456
+91 8880344456
+91-8880344456
08880344456
918880344456
Comment

Regular Expression for Detect Iranian Mobile Phone Numbers | IR mobile number Regex Pattern

--For Use In Pattern HTML Tag
$rexexPattern="(+98|0|98|0098)?([ ]|-|[()]){0,2}9[0-9]([ ]|-|[()]){0,2}(?:[0-9]([ ]|-|[()]){0,2}){8}";
--For Use In JavaScript
var
mobileReg = /(+98|0|98|0098)?([ ]|-|[()]){0,2}9[0-9]([ ]|-|[()]){0,2}(?:[0-9]([ ]|-|[()]){0,2}){8}/ig,
junkReg = /[^d]/ig,
persinNum = [/۰/gi,/۱/gi,/۲/gi,/۳/gi,/۴/gi,/۵/gi,/۶/gi,/۷/gi,/۸/gi,/۹/gi],
num2en = function (str){
  for(var i=0;i<10;i++){
    str=str.replace(persinNum[i],i);
  }
  return str;
},
getMobiles = function(str){
  var mobiles = num2en(str+'').match(mobileReg) || [];
  mobiles.forEach(function(value,index,arr){
    arr[index]=value.replace(junkReg,'');
    arr[index][0]==='0' || (arr[index]='0'+arr[index]);
  });
  return mobiles;
};

// test
console.log(getMobiles("jafang 0 91 2 (123) 45-67 jafang or +۹۸ (۹۱۵) ۸۰ ۸۰ ۸۸۸"));

/*
support all option like these
912 123 4567
912 1234 567
912-123-4567
912 (123) 4567
9 1 2 1 2 3 4 5 6 7
9 -1 (2 12))3 45-6 7
and all with +98 or 0
+989121234567
09121234567
9121234567
or even persian numbers +۹۸ (۹۱۵) ۸۰ ۸۰ ۸۸۸

and only detect true iranian operator numbers 091x 092x 093x 094x

*/
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript after dom ready 
Javascript :: fibonacci js code 
Javascript :: node express post request json 
Javascript :: how to just have createdAt mongoose 
Javascript :: javascript timestamp in seconds 
Javascript :: generate random string in javascript 
Javascript :: npm create react app 
Javascript :: loop over javascript using foreach 
Javascript :: form input field readonly angular 
Javascript :: js parse url decode 
Javascript :: columndefs in datatable not working while setting width jquery 
Javascript :: ecmascript 
Javascript :: how to detect a button click in javascript 
Javascript :: npm ERR! Missing script: "eject" react native 
Javascript :: new request javascript 
Javascript :: get the last option from select jquery 
Javascript :: json post fetch 
Javascript :: angular ng build Maximum call stack size exceeded 
Javascript :: datatable after render event 
Javascript :: trigger on change 
Javascript :: add mousedown event listener javascript 
Javascript :: svelte mount 
Javascript :: activate treeview menu in adminlte 3.0.2 treeview-menu open 
Javascript :: vue electron min width 
Javascript :: date format in ngx-csv package in angular 
Javascript :: write json file in node js 
Javascript :: react navigation transparent header 
Javascript :: cnpj pattern js 
Javascript :: ^(?:(+|00)d{1,3}[-s.])?(()?d{3,10}())?(?:[-s.)]d{2,7}([-s.]d{2,5})?([-s.]d{2})?)?$ 
Javascript :: sendgrid bulk hide each other on the email 
ADD CONTENT
Topic
Content
Source link
Name
5+6 =