^(\+98|0)?9\d{9}$
var regex = new RegExp('^(\\+98|0)?9\\d{9}$');
var result = regex.test('+989031234567');
console.log(result);
^(\+98|0)?9\d{9}$
var regex = new RegExp('^(\\+98|0)?9\\d{9}$');
var result = regex.test('+989031234567');
console.log(result);
Here we have a whole regex that validates Iranian phone numbers by separating the operator from each other
https://github.com/AmirMahdyJebreily/iranian-phonenumber-validation/graphs/traffic
you can use /^(0|09|09[0-9]{1,9})$/
in onchangetext
hey guys
you can use this regex and enjoy:
/^((98|\+98|0098|0)*(9)[0-9]{9})+$/
in this you can validation persian phone number like:
9120000000
09120000000
00989120000000
+989120000000
989120000000
also you can see this git repository and use other regex validating, filtering, sanitizing and finding Persian strings in laravel framework and kotlin.
^09(1[0-9] |2[0-2] |3[0-9] |9[0-9]) [0-9]{7}$
I think this is much better
/^(098|0098|98|\+98|0)?9(0[0-5]|[1 3]\d|2[0-3]|9[0-9]|41)\d{7}$/g
You can test it to make sure it works. This RegEx has also been updated.
https://regex101.com/