可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I want to validate Indian phone numbers as well as mobile numbers. The format of the phone number and mobile number is as follows:
For land Line number
03595-259506 03592 245902 03598245785
For mobile number
9775876662 0 9754845789 0-9778545896 +91 9456211568 91 9857842356 919578965389
I would like the regular expression in one regex. I have tried the following regex but it is not working properly.
{^\+?[0-9-]+$}
回答1:
For land Line Number
03595-259506 03592 245902 03598245785
you can use this
\d{5}([- ]*)\d{6}
NEW for all ;)
OLD: ((\+*)(0*|(0 )*|(0-)*|(91 )*)(\d{12}+|\d{10}+))|\d{5}([- ]*)\d{6} NEW: ((\+*)((0[ -]+)*|(91 )*)(\d{12}+|\d{10}+))|\d{5}([- ]*)\d{6} 9775876662 0 9754845789 0-9778545896 +91 9456211568 91 9857842356 919578965389 03595-259506 03592 245902 03598245785
this site is useful for me, and maby for you .;)http://gskinner.com/RegExr/
回答2:
This works really fine:
\+?\d[\d -]{8,12}\d
Matches:
03598245785 9775876662 0 9754845789 0-9778545896 +91 9456211568 91 9857842356 919578965389 987-98723-9898 +91 98780 98802 06421223054 9934-05-4851 WAQU9876567892 ABCD9876541212 98723-98765
Does NOT match:
2343 234-8700 1 234 765
回答3:
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
回答4:
For both mobile & fixed numbers: (?:\s+|)((0|(?:(\+|)91))(?:\s|-)*(?:(?:\d(?:\s|-)*\d{9})|(?:\d{2}(?:\s|-)*\d{8})|(?:\d{3}(?:\s|-)*\d{7}))|\d{10})(?:\s+|)
Explaination:
(?:\s+|) // leading spaces ((0|(?:(\+|)91)) // prefixed 0, 91 or +91 (?:\s|-)* // connecting space or dash (-) (?:(?:\d(?:\s|-)*\d{9})| // 1 digit STD code & number with connecting space or dash (?:\d{2}(?:\s|-)*\d{8})| // 2 digit STD code & number with connecting space or dash (?:\d{3}(?:\s|-)*\d{7})| // 3 digit STD code & number with connecting space or dash \d{10}) // plain 10 digit number (?:\s+|) // trailing spaces
I've tested it on following text
9775876662 0 9754845789 0-9778545896 +91 9456211568 91 9857842356 919578965389 0359-2595065 0352 2459025 03598245785 07912345678 01123456789 sdasdcsd +919898101353 dasvsd0 +91 dacsdvsad davsdvasd 0112776654
回答5:
You Can Use Regex Like This:
^[0-9\-\(\)\, ]+$
回答6:
All Landline Numbers and Mobile Number
^[\d]{2,4}[- ]?[\d]{3}[- ]?[\d]{3,5}|([0])?(\+\d{1,2}[- ]?)?[789]{1}\d{9}$
回答7:
This depends a lot on what you want the regex for: I had to import numbers from a rather dirty database to a new DB. So I wanted a liberal expression that just weeds out the completely wrong ones. Used this:
^\+?[\d(). -]{5,25}
Explaination
The phone number:
- may or may not start with a plus.
- could have one of these characters: ( ) . -
space
digit
. - should have between 5 to 25 characters.
(Side Note: According to ITU, phone numbers are limited to max of 15 digits Phone Numbering Plan. A max=25 accomodates the special characters.)
Visual Explaination

回答8:
var phonereg = /^(\+\d{1,3}[- ]?)?\d{10}$/;