Questions tagged [phone-number]

A telephone number or phone number is a sequence of digits used to call from one telephone line to another in a public switched telephone network(PSTN). When telephone numbers were invented, they were short — as few as one, two or three digits — and were given orally to a switchboard operator. As phone systems have grown and interconnected to encompass the world, telephone numbers have become longer.

A telephone number or phone number is a sequence of digits used to call from one telephone line to another in a public switched telephone network. When telephone numbers were invented, they were short — as few as one, two or three digits — and were given orally to a switchboard operator. As phone systems have grown and interconnected to encompass the world, telephone numbers have become longer. In addition to telephones, they now access other devices, such as computers and fax machines.

Telephone numbers must not be stored using numerical data types.

The format of telephone numbers internationally follows ITU-T Recommendation E.164, described here.

This is a useful reference for people creating software to handle telephone numbers: Falsehoods Programmers Believe About Phone Numbers.

1228 questions
1053
votes
45 answers

How to validate phone numbers using regex

I'm trying to put together a comprehensive regex to validate phone numbers. Ideally it would handle international formats, but it must handle US formats, including the following: 1-234-567-8901 1-234-567-8901 x1234 1-234-567-8901 ext1234 1 (234)…
Nicholas Trandem
  • 2,815
  • 5
  • 30
  • 32
503
votes
14 answers

How to mark-up phone numbers?

I want to mark up a phone number as callable link in an HTML document. I have read the microformats approach, and I know, that the tel: scheme would be standard, but is quite literally nowhere implemented. Skype defines, as far as I know, skype: and…
Boldewyn
  • 81,211
  • 44
  • 156
  • 212
497
votes
22 answers

Programmatically obtain the phone number of the Android phone

How can I programmatically get the phone number of the device that is running my android app?
jkap
  • 5,172
  • 3
  • 16
  • 9
337
votes
9 answers

Programmatically get own phone number in iOS

Is there any way to get own phone number by standard APIs from iPhone SDK?
Vadim
  • 9,383
  • 7
  • 36
  • 58
259
votes
6 answers

What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone

What's the longest possible worldwide phone number I should consider in SQL varchar(length) for phone. considerations: + for country code () for area code x + 6 numbers for Extension extension (so make it 8 {space}) spaces between groups (i.e. in…
237
votes
7 answers

How do I get the dialer to open with phone number displayed?

I don't need to call the phone number, I just need the dialer to open with the phone number already displayed. What Intent should I use to achieve this?
Nik
  • 7,114
  • 8
  • 51
  • 75
188
votes
26 answers

How to format a string as a telephone number in C#

I have a string "1112224444' it is a telephone number. I want to format as 111-222-4444 before I store it in a file. It is on a datarecord and I would prefer to be able to do this without assigning a new variable. I was…
Brian G
  • 53,704
  • 58
  • 125
  • 140
159
votes
4 answers

Remove all non-numeric characters from a string; [^0-9] doesn't match as expected

I'm trying to remove everything from a string but just numbers (0-9). I thought this would work.. echo preg_replace("[^0-9]","",'604-619-5135'); But it echos "604-619-5135". What am I missing???
jeffkee
  • 5,106
  • 12
  • 44
  • 76
130
votes
9 answers

Replace non-numeric with empty string

Quick add on requirement in our project. A field in our DB to hold a phone number is set to only allow 10 characters. So, if I get passed "(913)-444-5555" or anything else, is there a quick way to run a string through some kind of special replace…
Matt Dawdy
  • 19,247
  • 18
  • 66
  • 91
120
votes
22 answers

Formatting Phone Numbers in PHP

I am working on an SMS app and need to be able to convert the sender's phone number from +11234567890 to 123-456-7890 so it can be compared to records in a MySQL database. The numbers are stored in the latter format for use elsewhere on the site…
NightMICU
  • 9,000
  • 30
  • 89
  • 121
107
votes
25 answers

Calling a phone number in swift

I'm trying to call a number not using specific numbers but a number that is being called in a variable or at least tell it to pull up the number in your phone. This number that is being called in a variable is a number that I retrieved by using a…
Thomas Martinez
  • 1,631
  • 3
  • 16
  • 21
97
votes
11 answers

Which is best data type for phone number in MySQL and what should Java type mapping for it be?

I am using MySQL with the Spring JDBC template for my web application. I need to store phone numbers with only digits (10). I am a little bit confused about data type using data type. What is the preferable data type for it in MySQL? What should be…
Vishal Zanzrukia
  • 4,902
  • 4
  • 38
  • 82
74
votes
16 answers

Phone number validation Android

How do I check if a phone number is valid or not? It is up to length 13 (including character + in front). How do I do that? I tried this: String regexStr = "^[0-9]$"; String number=entered_number.getText().toString(); …
Uday
  • 5,933
  • 9
  • 44
  • 76
71
votes
15 answers

Read all contacts' phone numbers in android

I'm using this code to retrieve all contact names and phone numbers: String[] projection = new String[] { People.NAME, People.NUMBER }; Cursor c = ctx.getContentResolver().query(People.CONTENT_URI, projection, null, null, People.NAME + "…
shuwo
  • 879
  • 2
  • 8
  • 7
68
votes
18 answers

Phone validation regex

I'm using this pattern to check the validation of a phone number ^[0-9\-\+]{9,15}$ It's works for 0771234567 and +0771234567, but I want it to works for 077-1234567 and +077-1234567 and +077-1-23-45-67 and +077-123-45-6-7 What should I change in…
Nir
  • 1,882
  • 4
  • 26
  • 44
1
2 3
81 82