From RPM Wiki
| Table of contents |
Summary
This is additional information for development on phone number formatting in RPM. Please start with the Phone number formatting reference.
Scope
Phone number importing is applied to any phone number entered in the system in a dedicated phone number field or import.
Details
Initial processing
The following 2 things are always do to the input. This means before formatting or saving, regardless of what else we do to it.
- Trim leading & trailing spaces. This is always done first, even before the formatting is evaluated. Example: " 123" will always be saved as "123".
- Truncate the phone number to 99 characters if it is longer.
Manipulation
There are 3 scenarios where RPM will apply formatting to the phone number input before saving it. If the number doesn't match one of these then it is saved as entered.
1. If the number begins with "+1" or "+ 1". then we consider it a country code no matter what follows. Insert a space after the 1 (unless there is one there already).and leave the rest intact. If the start was "+ 1" then change it to "+1"
| Example input | Is saved as |
|---|---|
| +1234567890 | +1 234567890 |
| + 1234567890 | +1 234567890 |
| + 1 234567890 | +1 234567890 |
| +1,23,4 | +1 ,23,4 |
| +1ab,2.c | +1 ab,2.c |
| +11234-5567 123 | +1 1234-5567 123 |
| +1 1234-5567 123 | +1 1234-5567 123 |
| +1(555)1231234 | +1 (555)1231234 |
| + 1 1234567 | +1 1234567 |
2. 7 or 10 digits with no other character or correct characters
| Example input | Is saved as |
|---|---|
| 1234567 | 123-4567 |
| 123-4567 | 123-4567 |
| 123 4567 | 123-4567 |
| 1234567890 | (123) 456-7890 |
| 123-456-7890 | (123) 456-7890 |
| (123)4567890 | (123) 456-7890 |
| (123)456-7890 | (123) 456-7890 |
| (123) 4567890 | (123) 456-7890 |
| (123)-4567890 | (123) 456-7890 |
| (123) 456 7890 | (123) 456-7890 |
3. The above plus extension. We consider this case to be true if the first 10 numbers (plus formatting) fit the above and then are followed by any non-number character (ignore spaces). Anything after is considered the extension and is kept intact. A space is inserted between the formatted phone number and the extension (unless there is one there already). If there was more than one space in a row between the formatted number and the extension, it is reduced to one space.
| Example input | Is saved as |
|---|---|
| 1234567a123 | 123-4567 a123 |
| 123-4567 a123 | 123-4567 a123 |
| 123 4567 a1 | 123-4567 a1 |
| 123 4567 a1 b1 | 123-4567 a1 b1 |
| 123 4567 a1 b1 | 123-4567 a1 b1 |
| 1234567890x123,4abc.d | (123) 456-7890 x123,4abc.d |
| 123-456-7890z | (123) 456-7890 z |
| (123)4567890(z) | (123) 456-7890 (z) |
| (123)456-7890 %&! | (123) 456-7890 %&! |
| (123) 4567890+1 | (123) 456-7890 +1 |
| (123)-4567890+1+2+3 | (123) 456-7890 +1+2+3 |
| (123) 456 7890 x123 | (123) 456-7890 x123 |
4. Otherwise keep. The following don’t exactly fit any of the above 3 so they are saved unmodified.
| Example input | Is saved as |
|---|---|
| 123 | 123 |
| 1234 | 1234 |
| 12345 | 12345 |
| 12345678 | 12345678 |
| 1-2-3-4-5-6-7 | 1-2-3-4-5-6-7 |
| 123-4567 123 | 123-4567 123 |
| 123----3457 | 123----3457 |
| (1234)567 | (1234)567 |
| 1-23(456)7 | 1-23(456)7 |
| (403)555a1234 | (403)555a1234 |
| (123)4567 | (123)4567 |
| abcD | abcD |
| (555)abc1234 | (555)abc1234 |
| (403)kl5-1234 | (403)kl5-1234 |
| I am "so" cool! Are You? | I am "so" cool! Are You? |
| . | . |
| .1 | .1 |
| . - 1 | . - 1 |
- This page was last modified 15:47, 13 Jul 2009.
- This page has been accessed 845 times.
