473,397 Members | 1,949 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Phone Number vallidation for German phone number.

i want below numbers only should be validate.
0891234567
089-1234567
+49(89)123456
0049-89-123456
089 123456-78

Thanks in advance.
Jun 24 '16 #1
19 7150
Dormilich
8,658 Expert Mod 8TB
what have you tried?
Jun 26 '16 #2
i tried this below expression.
Expand|Select|Wrap|Line Numbers
  1. ^((?:\+\d+)?\s*(?:\(\d+\)\s*(?:[\/–-]\s*)?)?\d+(?:\s*(?:[\s\/–-]\s*)?\d+)*)$
this expression is allowed uk phone numbers.It should not allowed uk phone numbers.
PFB UK phone numbers.
01611234567
0161 123 4567
(0161) 123 4567
0161-123-4567
+44 161 123 4567
+441611234567
+44(0)161234567
00 44 161 1234567
(011) 44 161 234567
0161-158-5587
Jun 27 '16 #3
Dormilich
8,658 Expert Mod 8TB
this expression is allowed uk phone numbers.
that's because there is no restriction regarding the country code. you would have to replace +\d+ by +49 (at least)
Jun 27 '16 #4
is there any other format phone numbers other than below numbers for germany. If have send me the format numbers and regex.

0891234567
089-1234567
+49(89)123456
0049-89-123456
089 123456-78

Thanks.
Jun 27 '16 #5
I have tried below regular expression still some uk formats still executing.

Expand|Select|Wrap|Line Numbers
  1. ^((?:\+49|\+89)?\s*(?:\(([89|49])+\)\s*(?:[\/–-]\s*)?)?\d+(?:\s*(?:[\s\/–-]\s*)?\d+)*)$
.

below UK format numbers still executing.
00 44 161 1234567
0161-123-4567
0161 123 4567

for eg : 0161 123 4567 this format starting has 4 digits but for DE site has 3 digits. how to handle this scenario.

Thanks in advance.:)
Jun 27 '16 #6
Dormilich
8,658 Expert Mod 8TB
this expression is allowed uk phone numbers.
the only reliable phone format is the sequence of digits used to make a call, additionally using + to denote the call prefix (usually 00, but this may depend on the phone system used).

if you're calling within Germany, you simply replace the country code by the trunk code (0).

any other formatting (spaces, brackets, etc.) is nothing more than a visual aid to better remember the phone number and has no effect on the the functionality.

this essentially boils down to: (((\+|00+)49)|0)[1-9]\d+
Jun 27 '16 #7
Dormilich
8,658 Expert Mod 8TB
below UK format numbers still executing.
that's because you have made the country code optional.
Jun 27 '16 #8
Thanks Dormilich :).

can you tell where i have to place this expression "(((+|0{2,})49)|0)[1-9]\d+" in to this expression "^((?:\+49|\+89)?\s*(?:\(([89|49])+\)\s*(?:[\/–-]\s*)?)?\d+(?:\s*(?:[\s\/–-]\s*)?\d+)*)$".

Thanks in Advance :).
Jun 27 '16 #9
Dormilich
8,658 Expert Mod 8TB
nowhere. that would be a total replacement.
Jun 27 '16 #10
this expression((((+|0{2,})49)|0)[1-9]\d+) i s showing error in https://regex101.com/#javascript site.Please look into it.

Thanks.
Jun 27 '16 #11
Dormilich
8,658 Expert Mod 8TB
See fix at #7
Jun 27 '16 #12
i am not getting please send me perfect regex.
Jun 28 '16 #13
i have to restrict below format numbers for german phone number with the following regex.
Regex : ^((?:\+49|\+89)?\s*(?:\(([89|49])+\)\s*(?:[\/–-]\s*)?)?\d+(?:\s*(?:[\s\/–-]\s*)?\d+)*)$

Numbers : 00 44 161 1234567,0161-123-4567,0161 123 4567
Jun 28 '16 #14
Dormilich
8,658 Expert Mod 8TB
it's not going to work with this RegExp as long as the country code is optional.
Jun 28 '16 #15
i have to restrict at-least this number.
00 44 161 1234567
Jun 28 '16 #16
Dormilich
8,658 Expert Mod 8TB
with a bit of preparation, my RegExp works.
Jun 28 '16 #17
i am using this regex(^((?:\+49|\+89)?\s*(?:\(([89|49])\d+\)\s*(?:[\/–-]\s*)?)?\d+(?:\s*(?:[\s\/–-]\s*)(?!44{1,2})\d+)*)$) it is working fine but i have one query.

suppose if the number does not allow using this regex(?!44) .If we allow the number what we have to use.
Jun 28 '16 #18
Dormilich
8,658 Expert Mod 8TB
youre making it unnecessarily complicated with this RegExp. there is no need to regard spaces, parentheses, hyphens, dots, and whatnot in a number validation.

the RegExp I posted in #7 is sufficient.
Jun 28 '16 #19
Thanks Dormilich, for supporting and much appreciated. if the number having like 00 44 161 1234567.this number has 00 44 has uk code right, this one i have to restrict.
Jun 28 '16 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: William Morris | last post by:
Our application tracks contact information. One of our clients, a car dealership, has asked about being able to enter a lastname and phone number and getting as much of the main form filled out as...
3
by: Hai Nguyen | last post by:
Hi All I have a textbox want to mask as phone box. How can I do it? Thanks
6
by: Michael R | last post by:
I haven't found anything that would help me to understand the correct syntax for having a certain number of digits phone number validation rule. My input mask for this field is: \000\-0000000;;...
9
by: Alex | last post by:
Get the Name and Phone Number of the Current Windows User in a .NET Application I am writing a simple .NET (C#) application. It needs to "automatic" get the Name (last, first) and phone number...
1
by: Seth Williams | last post by:
I've got a strange problem - - I've got an input form (members), which has standard data, name, address, phone, etc I've changed the table now, so that the phone number accepts a varchar(25) - I...
20
by: changwl8888 | last post by:
How do i convert an alphabetic phone number to a numeric phone number? Translating alphabetic number: Enter phone number:1-800-COL-LECT 1-800-265-5328
4
by: luke noob | last post by:
This is my HTML... <head> <script type="text/javascript" src="js/jquery-1.2.6.pack.js"></script> <script type="text/javascript" src="js/script.js"></script> </head> <body>
5
by: karthick001 | last post by:
Hello Folks, Calling a phone number in my phone on a button click from my desktop application(PC). This is my objective, all i know is creating desktop applications with some basic...
1
by: ONewbie | last post by:
Hello, I am very new to PHP, so I would greatly appreciate your help. I am making a contact form with Name, Email and Phone text boxes. Validating email and name seems to be working fine, but...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.