TheVoĉoTheVoĉo
ConfigurationAdvanced

Number Reformatting

Transform phone numbers to match your trunk provider's expected format. Providers may send or expect numbers in different formats (E.164, local, national). Number reformatting ensures compatibility by adding prefixes, stripping digits, or completely transforming number formats based on patterns.

Understanding Number Formats

Common Phone Number Formats:

E.164 International (Standard):

Format: +[Country Code][Number]
Examples:
  US: +15551234567
  UK: +442071234567
  Australia: +61212345678
Characteristics:
  - Starts with +
  - Country code included
  - No spaces or special characters
  - Universal standard

National Format:

Format: 0[Area Code][Number] or [Area Code][Number]
Examples:
  US: 5551234567 (10 digits)
  UK: 02071234567 (11 digits with leading 0)
  France: 0123456789 (10 digits with leading 0)
Characteristics:
  - No country code
  - May include trunk prefix (0)
  - Domestic format

Local Format:

Format: [Number] (no area code)
Examples:
  US: 5551234567 (if within same area code)
  Local: 1234567 (7 digits)
Characteristics:
  - Shortest format
  - Assumes local calling
  - Context-dependent

Display Format (Non-Routable):

Format: (###) ###-####
Examples:
  US: (555) 123-4567
  International: +1 (555) 123-4567
Characteristics:
  - Human-readable
  - Includes formatting characters
  - Must be normalized for routing

Why Reformatting is Needed

Provider-Specific Format Requirements

Scenario 1: Provider Expects E.164

Provider: Sends and expects +15551234567
Your PBX: Stores numbers as 5551234567
Problem: Format mismatch causes routing failures

Solution:
  Inbound: Strip +1 from received numbers
  Outbound: Add +1 to sent numbers
Result: Seamless compatibility

Scenario 2: Provider Sends Local Format

Provider: Sends 5551234567 (no country code)
Your PBX: Expects +15551234567 (E.164)
Problem: Caller ID doesn't display correctly

Solution:
  Inbound: Add +1 to all inbound caller IDs
  Rule: Prepend +1 to 10-digit numbers
Result: Normalized to E.164 in your system

Scenario 3: Provider Varies by Destination

Provider behavior:
  US calls: Sends 5551234567
  International: Sends +442071234567
Problem: Inconsistent formatting

Solution:
  Rule 1: If starts with digit, prepend +1
  Rule 2: If starts with +, leave as-is
Result: All numbers E.164 format

Scenario 4: Provider Includes Country Code Without +

Provider: Sends 15551234567 (no + sign)
Standard: Should be +15551234567
Problem: Number parsing fails

Solution:
  Inbound: Prepend + to all inbound caller IDs
  Pattern: ^[0-9]+ → +[0-9]+
Result: Proper E.164 format

Test First

Before deploying reformatting rules, test with your specific provider. Get sample call logs to see actual formats sent/received.

Geographic Number Format Differences

United States/Canada (+1):

Standard: 10 digits (area code + number)
E.164: +15551234567
National: 5551234567 or 1-555-123-4567
Local: 5551234567 (area code included even locally)

Common Issues:
  - Provider may omit leading +1
  - Display format includes dashes/parentheses
  - Toll-free (800, 888, 877, etc.) same format

United Kingdom (+44):

Standard: 10-11 digits
E.164: +442071234567
National: 02071234567 (leading 0)
Note: Leading 0 is trunk prefix, not part of E.164

Reformatting:
  E.164 to National: Replace +44 with 0
  National to E.164: Replace leading 0 with +44

Germany (+49):

Standard: Variable length (10-13 digits)
E.164: +493012345678
National: 03012345678 (leading 0)

Reformatting:
  E.164 to National: Replace +49 with 0
  National to E.164: Replace leading 0 with +49

Australia (+61):

Standard: 10 digits
E.164: +61212345678
National: 0212345678 (leading 0)

Reformatting:
  E.164 to National: Replace +61 with 0
  National to E.164: Replace leading 0 with +61

France (+33):

Standard: 10 digits
E.164: +33123456789
National: 0123456789 (leading 0)

Reformatting:
  E.164 to National: Replace +33 with 0
  National to E.164: Replace leading 0 with +33

Japan (+81):

Standard: 10-11 digits
E.164: +81312345678
National: 0312345678 (leading 0)
Note: Mobile numbers start with 70, 80, 90

Reformatting:
  E.164 to National: Replace +81 with 0
  National to E.164: Replace leading 0 with +81

International Complexity

Each country has unique formatting rules. Research specific country requirements when configuring international trunks.

Multi-System Interoperability

PBX to CRM Integration:

PBX Format: +15551234567 (E.164)
CRM Format: (555) 123-4567 (Display)
Problem: Number doesn't match in CRM lookup

Solution 1: Normalize in CRM
  Convert CRM display to E.164 for matching

Solution 2: Reformat PBX outbound
  Convert E.164 to display format for CRM

Solution 3: Both
  PBX and CRM both normalize to E.164 internally
  Display formatting only for UI

Multi-Trunk Scenarios:

Trunk A (US Provider): Expects 5551234567
Trunk B (International): Expects +15551234567
Trunk C (Legacy): Expects 15551234567

Outbound Rules:
  Route to Trunk A: Strip +1 prefix
  Route to Trunk B: Keep E.164 format
  Route to Trunk C: Strip + only, keep country code

Result: Each trunk receives its expected format

Call Center Software Integration:

Call Center: Expects E.164 for all operations
PBX: Receives varied formats from providers
Solution: Normalize all inbound to E.164 immediately

Benefits:
  - Screen pop works reliably
  - Call logging consistent
  - Reporting accurate
  - Callbacks use correct format

Mobile App Integration:

Mobile App: Sends numbers in user's device format
Could be: Local, national, international, with formatting
PBX: Needs consistent format for routing

Solution: Strip all formatting characters, normalize to E.164
  Input: (555) 123-4567
  Strip: 5551234567
  Normalize: +15551234567
  Result: Routes correctly

Standardize Internally

Best practice: Normalize everything to E.164 internally, reformat only at boundaries (provider, display) as needed.

Why Consistency Matters

Problem: Inconsistent Number Storage

Same customer, multiple formats in system:
  Call 1: 5551234567
  Call 2: +15551234567
  Call 3: (555) 123-4567
  Call 4: 1-555-123-4567

Result:
  - CRM sees as 4 different contacts
  - Call history fragmented
  - Duplicate records
  - Analytics inaccurate

Solution: Immediate Normalization

All inbound calls:
  - Strip formatting characters
  - Normalize to E.164
  - Store as +15551234567
  
All outbound calls:
  - User enters any format
  - System normalizes to E.164
  - Reformat for trunk if needed
  - Store normalized version in CDR

Result: Single source of truth

Caller ID Matching:

Without Normalization:
  Incoming: 5551234567
  Stored: +15551234567
  Match: Fails (different format)
  Result: Customer not recognized

With Normalization:
  Incoming: 5551234567 → normalized to +15551234567
  Stored: +15551234567
  Match: Success
  Result: Customer recognized, screen pop works

Do Not Call (DNC) Lists:

DNC Entry: +15551234567
Outbound Target: 5551234567
Without normalization: Not matched, call goes through
With normalization: Matched, call blocked

Critical for compliance

Reporting Accuracy:

Report: Calls by number
Without normalization:
  5551234567: 10 calls
  +15551234567: 8 calls
  (555) 123-4567: 5 calls
  Total: Appears as 3 different numbers (23 calls)

With normalization:
  +15551234567: 23 calls
  Total: Accurate count

Data Quality

Inconsistent number formatting leads to data quality issues, duplicate records, and inaccurate reporting. Normalize early and consistently.


Add Reformatting Rules

Create Number Reformatting Rule

Go to Settings > Trunks > [Select Trunk] > Advanced > Number Reformatting > Click Add Rule

Configure Rule Details

Basic Information:

Rule Name: Normalize-Inbound-US-Numbers
Direction: Inbound (or Outbound)
Match Pattern: ^([0-9]{10})$
Replacement: +1\1
Priority: 1
Enabled: Yes

Fields:

  • Rule Name: Descriptive identifier
  • Direction: Inbound (received numbers) or Outbound (sent numbers)
  • Match Pattern: Regex or wildcard pattern to match numbers
  • Replacement: How to transform matched numbers
  • Priority: Processing order (lower number = higher priority)
  • Enabled: Toggle rule on/off

Testing

Always test rules with sample numbers before enabling in production. One wrong rule can break all calls.

Define Match Pattern

Pattern Examples:

Match 10-digit US numbers:

Pattern: ^([0-9]{10})$
Matches: 5551234567
Doesn't match: +15551234567, 555-123-4567

Match E.164 US numbers:

Pattern: ^\+1([0-9]{10})$
Matches: +15551234567
Doesn't match: 5551234567, +442071234567

Match any international:

Pattern: ^\+([0-9]+)$
Matches: +15551234567, +442071234567, +61212345678
Doesn't match: 5551234567 (no +)

Match UK national format:

Pattern: ^0([0-9]{10})$
Matches: 02071234567
Doesn't match: +442071234567, 2071234567

Define Replacement Pattern

Replacement Examples:

Add +1 prefix:

Match: ^([0-9]{10})$
Replace: +1\1
Example: 5551234567 → +15551234567

Remove +1 prefix:

Match: ^\+1([0-9]{10})$
Replace: \1
Example: +15551234567 → 5551234567

Replace +44 with 0 (UK):

Match: ^\+44([0-9]+)$
Replace: 0\1
Example: +442071234567 → 02071234567

Replace 0 with +44 (UK):

Match: ^0([0-9]+)$
Replace: +44\1
Example: 02071234567 → +442071234567

Add country code to any number without +:

Match: ^([0-9]+)$
Replace: +1\1
Example: 5551234567 → +15551234567

Test and Enable

Testing:

  1. Use pattern tester with sample numbers
  2. Verify transformations correct
  3. Test edge cases (short numbers, international)
  4. Test with multiple samples

Enable:

  1. Save rule
  2. Enable rule
  3. Make test calls
  4. Verify CDR shows correct number format
  5. Monitor for issues

Rule Active

Number reformatting rule is active. All matching numbers will be transformed according to your configuration.

Common Reformatting Rule Types

Type 1: Add Prefix

Purpose: Add country code or prefix to numbers
Match: ^([0-9]{10})$
Replace: +1\1
Result: 5551234567 → +15551234567
Use: Normalize US numbers to E.164

Type 2: Strip Prefix

Purpose: Remove country code or prefix
Match: ^\+1([0-9]{10})$
Replace: \1
Result: +15551234567 → 5551234567
Use: Provider expects national format

Type 3: Replace Prefix

Purpose: Change one prefix to another
Match: ^0([0-9]+)$
Replace: +44\1
Result: 02071234567 → +442071234567
Use: Convert UK national to E.164

Type 4: Strip Characters

Purpose: Remove formatting characters
Match: [^0-9+]
Replace: (empty)
Result: (555) 123-4567 → 5551234567
Use: Clean user input

Type 5: Add Area Code

Purpose: Add area code to 7-digit local numbers
Match: ^([0-9]{7})$
Replace: 555\1
Result: 1234567 → 5551234567
Use: Complete local numbers

Type 6: Conditional Formatting

Purpose: Different rules for different patterns
Rule 1: ^([0-9]{10})$ → +1\1 (US)
Rule 2: ^\+([0-9]+)$ → +\1 (already international)
Rule 3: ^011([0-9]+)$ → +\1 (replace 011 with +)
Use: Handle multiple input formats

Type 7: Extract Portion

Purpose: Extract only part of number
Match: ^\+1([0-9]{3})([0-9]{3})([0-9]{4})$
Replace: \1-\2-\3
Result: +15551234567 → 555-123-4567
Use: Display formatting

Type 8: Remove Anonymous

Purpose: Standardize anonymous caller ID
Match: ^(anonymous|private|restricted)$
Replace: Anonymous
Result: "Private" → "Anonymous"
Use: Consistent anonymous handling

Combine Rules

Multiple rules can work together. Process in priority order to handle complex transformations.

Regex Pattern Reference

Basic Patterns:

Exact Digit Count:

Pattern: ^[0-9]{10}$
Meaning: Exactly 10 digits
Matches: 5551234567
Doesn't match: 555123456 (9 digits), 55512345678 (11 digits)

Digit Range:

Pattern: ^[0-9]{10,11}$
Meaning: 10 or 11 digits
Matches: 5551234567, 55512345678

Optional Plus Sign:

Pattern: ^\+?[0-9]+$
Meaning: Optional + at start, then digits
Matches: +15551234567, 15551234567

Capture Groups:

Pattern: ^(\+1)?([0-9]{10})$
Meaning: Optional +1, capture 10 digits
Group 1: \1 = +1 (if present)
Group 2: \2 = 5551234567

Advanced Patterns:

US Number with Optional Country Code:

Pattern: ^(\+?1)?([0-9]{3})([0-9]{3})([0-9]{4})$
Groups:
  \1 = +1 or 1 or empty
  \2 = area code (555)
  \3 = exchange (123)
  \4 = number (4567)
Replace: +1\2\3\4
Result: Always E.164

International Number:

Pattern: ^\+([1-9][0-9]{0,3})([0-9]{4,14})$
Groups:
  \1 = country code (1-4 digits, doesn't start with 0)
  \2 = national number (4-14 digits)
Validates: Proper E.164 structure

UK Number (National to E.164):

Pattern: ^0([0-9]{10})$
Replace: +44\1
Example: 02071234567 → +442071234567

Remove All Non-Numeric Except +:

Pattern: [^0-9+]
Replace: (empty)
Result: Removes spaces, dashes, parentheses
Example: +1 (555) 123-4567 → +15551234567

Anonymous Caller Variations:

Pattern: ^(anonymous|private|restricted|unknown|unavailable)$
Flags: Case-insensitive
Replace: Anonymous
Standardizes all variations

Toll-Free Numbers:

Pattern: ^1?(8(00|88|77|66|55|44|33))[0-9]{7}$
Matches: 18001234567, 8881234567, etc.
Use: Special handling for toll-free

Test Patterns

Always test regex patterns with multiple test cases. Small errors can match/transform unexpected numbers.

Rule Processing Order

How Priority Works:

Priority 1: Processed first (highest priority)
Priority 2: Processed second
Priority 3: Processed third
...
Priority 99: Processed last (lowest priority)

First match wins: Once a rule matches, processing stops

Example Priority Configuration:

Priority 1: Clean Input

Rule: Strip all non-numeric except +
Pattern: [^0-9+]
Replace: (empty)
Result: +1 (555) 123-4567 → +15551234567

Purpose: Clean input first before pattern matching

Priority 2: Handle Already-Formatted

Rule: Leave E.164 as-is
Pattern: ^\+[1-9][0-9]+$
Replace: \0 (no change)
Result: +15551234567 → +15551234567

Purpose: Don't modify already correct format

Priority 3: Add US Country Code

Rule: Normalize 10-digit US numbers
Pattern: ^([0-9]{10})$
Replace: +1\1
Result: 5551234567 → +15551234567

Purpose: Convert national to E.164

Priority 4: Add US Country Code (with 1)

Rule: Normalize 11-digit with leading 1
Pattern: ^1([0-9]{10})$
Replace: +1\1
Result: 15551234567 → +15551234567

Purpose: Handle leading 1 (US dialing prefix)

Priority 5: Handle 7-digit Local

Rule: Add area code to local numbers
Pattern: ^([0-9]{7})$
Replace: 555\1 (your local area code)
Result: 1234567 → 5551234567

Purpose: Complete local numbers
Note: Then processed by priority 3 rule

Best Practice Priority Order:

  1. Strip formatting characters (clean input)
  2. Leave already-correct format alone
  3. Most specific patterns (e.g., exact digit count)
  4. Less specific patterns (e.g., ranges)
  5. Catch-all/default rules

Testing Priority:

Test Number: (555) 123-4567

Priority 1 (Strip formatting): (555) 123-4567 → 5551234567
Priority 2 (E.164 check): Doesn't match (no +)
Priority 3 (10-digit US): Matches → +15551234567
Priority 4+: Skipped (already matched)

Final Result: +15551234567

Multiple Direction Rules:

Inbound Rules (separate priority):
  Priority 1: Add +1 to 10-digit inbound
  Priority 2: Leave international as-is

Outbound Rules (separate priority):
  Priority 1: Strip +1 for trunk
  Priority 2: Convert E.164 to national

Independent processing per direction

Order Matters

Rule priority critically important. Wrong order can cause rules to never match or match incorrectly. Test with various inputs.


Common Scenarios

Normalize All Numbers to E.164

Goal: Convert all inbound numbers to E.164 format for consistency

Rule Set:

Rule 1: Strip Formatting Characters

Priority: 1
Direction: Inbound
Pattern: [^0-9+]
Replace: (empty)
Example: (555) 123-4567 → 5551234567
Purpose: Clean input

Rule 2: Already E.164

Priority: 2
Direction: Inbound
Pattern: ^\+[1-9][0-9]+$
Replace: \0 (no change)
Example: +15551234567 → +15551234567
Purpose: Leave valid E.164 unchanged

Rule 3: 10-Digit US

Priority: 3
Direction: Inbound
Pattern: ^([0-9]{10})$
Replace: +1\1
Example: 5551234567 → +15551234567
Purpose: Add country code

Rule 4: 11-Digit US (with 1)

Priority: 4
Direction: Inbound
Pattern: ^1([0-9]{10})$
Replace: +1\1
Example: 15551234567 → +15551234567
Purpose: Handle US dialing prefix

Rule 5: International without +

Priority: 5
Direction: Inbound
Pattern: ^011([0-9]+)$
Replace: +\1
Example: 01144201234567 → +442012345678
Purpose: Convert US international prefix

Rule 6: UK National

Priority: 6
Direction: Inbound
Pattern: ^0([0-9]{10})$
Replace: +44\1
Example: 02071234567 → +442071234567
Purpose: UK-specific conversion

Result: All inbound numbers normalized to E.164

Universal Format

E.164 normalization provides single consistent format throughout your system. Simplifies integration, reporting, and CRM matching.

Adapt to Provider Requirements

Scenario 1: Provider Expects National Format

Inbound (Provider → PBX):

Rule: Normalize to E.164
Pattern: ^([0-9]{10})$
Replace: +1\1
Result: Store as +15551234567 in PBX

Outbound (PBX → Provider):

Rule: Strip country code
Pattern: ^\+1([0-9]{10})$
Replace: \1
Result: Send as 5551234567 to provider

Scenario 2: Provider Inconsistent

Provider sends:

  • US numbers: 5551234567 (no +1)
  • International: +442071234567 (with +)

Rules:

Inbound Rule 1: If no +, assume US
Pattern: ^([0-9]{10})$
Replace: +1\1

Inbound Rule 2: If has +, leave as-is  
Pattern: ^\+([0-9]+)$
Replace: +\1

Result: Consistent E.164 internally

Scenario 3: SIP Provider Needs 011

Provider expects:

  • US: 5551234567
  • International: 01144201234567 (not +44)

Outbound Rules:

Rule 1: US numbers (strip +1)
Pattern: ^\+1([0-9]{10})$
Replace: \1

Rule 2: International (replace + with 011)
Pattern: ^\+([0-9]+)$
Replace: 011\1

Result: 
  +15551234567 → 5551234567
  +442071234567 → 01144201234567

Scenario 4: Provider Includes +, PBX Doesn't Expect It

Provider sends: +15551234567 PBX routing: Expects 5551234567

Inbound Rule:

Pattern: ^\+1([0-9]{10})$
Replace: \1
Result: +15551234567 → 5551234567

Provider Documentation

Always check provider documentation for expected formats. Test with provider support before production deployment.

Converting Local/National to International

US: Local to E.164

Scenario: 7-digit local number to full E.164
Local: 1234567
Area Code: 555 (your location)

Rule 1: Add area code
Pattern: ^([0-9]{7})$
Replace: 555\1
Result: 1234567 → 5551234567

Rule 2: Add country code (from previous scenario)
Pattern: ^([0-9]{10})$
Replace: +1\1
Result: 5551234567 → +15551234567

UK: National to E.164

Scenario: UK national to international
National: 02071234567 (London landline)

Rule:
Pattern: ^0([0-9]{10})$
Replace: +44\1
Result: 02071234567 → +442071234567

Germany: National to E.164

National: 03012345678 (Berlin)

Rule:
Pattern: ^0([0-9]+)$
Replace: +49\1
Result: 03012345678 → +493012345678

France: National to E.164

National: 0123456789

Rule:
Pattern: ^0([0-9]{9})$
Replace: +33\1
Result: 0123456789 → +33123456789

Australia: National to E.164

National: 0212345678 (Sydney)

Rule:
Pattern: ^0([0-9]{9})$
Replace: +61\1
Result: 0212345678 → +61212345678

Multi-Country Support:

Rule 1: UK (leading 0, 11 digits total)
Pattern: ^0([0-9]{10})$
Replace: +44\1

Rule 2: Germany (leading 0, variable length)
Pattern: ^0([0-9]{9,12})$
Replace: +49\1

Rule 3: France (leading 0, 10 digits total)
Pattern: ^0([0-9]{9})$
Replace: +33\1

Rule 4: US (10 digits, no leading 0)
Pattern: ^([0-9]{10})$
Replace: +1\1

Priority order: Most specific to least specific

Country-Specific Rules

Each country has unique formats. Research target country before implementing rules. Test thoroughly with real numbers.

Formatting for Display (Non-Routing)

US Display Format:

Input: +15551234567
Pattern: ^\+1([0-9]{3})([0-9]{3})([0-9]{4})$
Replace: (\1) \2-\3
Output: (555) 123-4567
Use: Caller ID display, call logs

International Display:

Input: +442071234567
Pattern: ^\+([0-9]+)([0-9]{4})$
Replace: +\1 (...) \2
Output: +44207 (...) 4567
Use: Abbreviated display for long numbers

Hide Number Partially (Privacy):

Input: +15551234567
Pattern: ^\+1([0-9]{3})([0-9]{3})([0-9]{4})$
Replace: +1\1***\3
Output: +1555***4567
Use: Privacy mode in shared displays

Consistent Caller ID Display:

Rule: Always display as (###) ###-####
Input: +15551234567, 5551234567, 555-123-4567

Normalization: All to +15551234567
Display: All shown as (555) 123-4567
Result: Consistent appearance

Name + Number Display:

Format: [Name] ([Number])
Example: John Smith (555) 123-4567
Implementation: Lookup name, format number, combine

Display Only

Display formatting should not affect routing. Always maintain E.164 internally, format only for presentation.


Import Rules

Import Multiple Reformatting Rules

Prepare Import File

Create CSV with reformatting rules:

rule_name,direction,priority,pattern,replacement,enabled
US-10-Digit-Normalize,inbound,1,^([0-9]{10})$,+1\1,true
US-11-Digit-Normalize,inbound,2,^1([0-9]{10})$,+1\1,true
Strip-US-Outbound,outbound,1,^\+1([0-9]{10})$,\1,true
UK-National-to-E164,inbound,3,^0([0-9]{10})$,+44\1,true
Strip-Formatting,inbound,0,[^0-9+],,true

Import File

Navigate to Number Reformatting > Import Rules > Upload CSV

Review Preview

System shows preview of rules to be imported:

  • Total rules: 5
  • Valid rules: 5
  • Errors: 0

Check each rule for correctness

Confirm Import

Click Confirm Import

Import Complete

All reformatting rules imported. Test with sample numbers to verify correct operation.

CSV File Structure

Required Columns:

rule_name: Descriptive name (string)
direction: inbound or outbound
priority: Integer (0-999)
pattern: Regex pattern (string)
replacement: Replacement pattern (string, can be empty)
enabled: true or false

Optional Columns:

description: Rule description/notes
trunk_id: Specific trunk (if empty, applies to all)
apply_to: all, caller_id, destination
notes: Additional notes

Example Complete CSV:

rule_name,direction,priority,pattern,replacement,enabled,description
Strip-Formatting,inbound,0,[^0-9+],,true,Remove all non-numeric except +
Leave-E164,inbound,1,^\+[1-9][0-9]+$,\0,true,Don't modify valid E.164
US-10-Digit,inbound,2,^([0-9]{10})$,+1\1,true,Add +1 to 10-digit numbers
US-11-Digit,inbound,3,^1([0-9]{10})$,+1\1,true,Normalize 11-digit with leading 1
UK-National,inbound,4,^0([0-9]{10})$,+44\1,true,Convert UK national to E.164
Strip-US-Out,outbound,1,^\+1([0-9]{10})$,\1,true,Remove +1 for provider

Special Characters in CSV:

  • Escape commas in pattern/replacement
  • Use quotes if pattern contains commas
  • Escape backslashes: \ for \

Example with Special Characters:

rule_name,pattern,replacement
"Complex-Rule","^(\+?1)?([0-9]{3})([0-9]{3})([0-9]{4})$","+1\2\3\4"

Excel Export

Create rules in Excel for easier editing, then export to CSV. Ensure UTF-8 encoding when exporting.

Import Validation

Validation Checks:

Pattern Syntax:

Check: Is regex pattern valid?
Invalid: ^([0-9]{10}  (missing closing parenthesis)
Valid: ^([0-9]{10})$
Error: "Invalid regex syntax in pattern"

Replacement References:

Check: Do capture groups exist?
Pattern: ^([0-9]{10})$  (1 capture group)
Replacement: +1\1\2  (references 2 groups)
Error: "Replacement references non-existent group \2"

Priority Conflicts:

Check: Multiple rules with same priority?
Rule 1: Priority 1
Rule 2: Priority 1
Warning: "Multiple rules with priority 1, may have undefined order"

Direction Values:

Check: Direction is 'inbound' or 'outbound'?
Invalid: Direction = "incoming"
Valid: Direction = "inbound"
Error: "Invalid direction value"

Enabled Values:

Check: Enabled is true/false or 1/0
Valid: true, false, 1, 0, yes, no
Invalid: maybe, sometimes
Error: "Invalid enabled value"

Duplicate Rule Names:

Check: Rule name unique?
Existing: US-10-Digit-Normalize
Import: US-10-Digit-Normalize
Action: Skip, overwrite, or rename

Testing Imported Rules:

After import:
1. Test pattern tester with sample numbers
2. Verify each rule matches correctly
3. Check replacement produces expected result
4. Make test call through trunk
5. Verify CDR shows correct format

Validate Before Enabling

Always validate imported rules before enabling. Invalid rules can break all calls on the trunk.

Pre-Made Rule Libraries

Library 1: US E.164 Normalization

Rules: 5
Purpose: Normalize all US numbers to E.164
Includes:
  - Strip formatting
  - 10-digit conversion
  - 11-digit conversion
  - Leave valid E.164
  - Handle 7-digit local
Download: us-e164-normalization.csv

Library 2: Multi-Country Inbound

Rules: 10
Purpose: Normalize international numbers to E.164
Includes:
  - US, UK, Germany, France, Australia
  - National to E.164 conversion
  - Handle leading 0 (international trunk prefix)
Download: multi-country-inbound.csv

Library 3: Provider Compatibility - National Format

Rules: 2
Purpose: Convert E.164 to national format for provider
Includes:
  - Strip +1 for US
  - Leave non-US international
Download: provider-national-format.csv

Library 4: Display Formatting

Rules: 3
Purpose: Format numbers for display
Includes:
  - US: (###) ###-####
  - International: +## ... ####
  - Anonymous: "Anonymous"
Download: display-formatting.csv

Library 5: Comprehensive US System

Rules: 8
Purpose: Complete US number handling (inbound + outbound)
Includes:
  - Inbound normalization
  - Outbound provider formatting
  - Display formatting
  - Anonymous handling
Download: comprehensive-us-system.csv

Custom Library Creation:

  1. Export current rules
  2. Modify/add rules in Excel
  3. Test thoroughly
  4. Save as new library
  5. Document purpose and scope
  6. Share with team or community

Community Libraries

Many providers offer pre-made rule libraries for their specific requirements. Check provider documentation or support.


Best Practices

Reformatting Recommendations

Follow best practices for reliable, maintainable number reformatting configuration.

Rule Design

  1. Normalize Internally: Store all numbers as E.164, reformat only at boundaries
  2. Test Thoroughly: Test every rule with 10+ sample numbers before enabling
  3. Priority Order: Process formatting cleanup first, then specific patterns
  4. Capture Groups: Use capture groups for flexible transformations
  5. Document Rules: Add clear descriptions explaining purpose of each rule

Pattern Matching

  1. Anchor Patterns: Use ^ and $ to match entire string (avoid partial matches)
  2. Specific First: More specific patterns (exact digit count) higher priority
  3. Validate Input: Check pattern matches expected input format
  4. Escape Special: Properly escape regex special characters (+, ., *, etc.)
  5. Test Edge Cases: Test with shortest, longest, and unusual numbers

Maintenance

  1. Version Control: Keep history of rule changes
  2. Export Regularly: Export rules as backup before major changes
  3. Monitor CDRs: Review CDRs to ensure numbers formatted correctly
  4. Update for Changes: Update rules when provider changes requirements
  5. Audit Quarterly: Review all rules quarterly, remove obsolete ones

Performance

  1. Minimize Rules: Fewer rules = faster processing
  2. Optimize Patterns: Simple patterns faster than complex regex
  3. Priority Placement: Most common matches first
  4. Avoid Overlaps: Prevent multiple rules matching same number
  5. Test Performance: Monitor call setup time with rules enabled

Integration

  1. CRM Matching: Ensure reformatting compatible with CRM number format
  2. Call Tracking: Maintain consistency for accurate attribution
  3. DNC Lists: Normalize DNC list numbers same way as inbound
  4. API Webhooks: Provide consistent format to external systems
  5. Reporting: Use E.164 internally for accurate reporting

Troubleshooting

Pattern Not Matching Expected Numbers

Problem: Numbers not being transformed despite rule enabled

Diagnostics:

1. Check Pattern Syntax:

Rule pattern: ^([0-9]{10}$
Problem: Missing closing parenthesis
Fix: ^([0-9]{10})$

2. Test Pattern in Pattern Tester:

Pattern: ^([0-9]{10})$
Test: +15551234567
Result: No match (has +1 prefix)
Fix: Either strip +1 first or match with optional prefix

3. Check Rule Priority:

Priority 1: ^\+([0-9]+)$ (matches first, stops processing)
Priority 2: ^([0-9]{10})$ (never reached)
Fix: Reorder priorities or make patterns mutually exclusive

4. Verify Rule Enabled:

Status: Rule shows disabled
Fix: Enable rule

5. Check Direction:

Rule Direction: Outbound
Problem: Testing with inbound call
Fix: Verify testing correct direction

6. Review Call Logs:

CDR entry: Shows original number unchanged
Check: "Number reformatting applied" field
If No: Pattern didn't match
Action: Adjust pattern

Pattern Tester

Always use pattern tester tool before deploying. Shows exactly which patterns match which numbers and why.

Rule Transforms Incorrectly

Problem: Pattern matches but produces wrong output

Scenario 1: Wrong Capture Group

Pattern: ^([0-9]{3})([0-9]{3})([0-9]{4})$
Replacement: +1\3\2\1
Input: 5551234567
Expected: +15551234567
Actual: +145671235555
Problem: Groups reversed
Fix: +1\1\2\3

Scenario 2: Missing Capture Group

Pattern: ^[0-9]{10}$
Replacement: +1\1
Input: 5551234567
Error: "No capture group \1"
Fix: Pattern needs parentheses: ^([0-9]{10})$

Scenario 3: Escaping Issue

Pattern: ^\+1([0-9]{10})$
Replacement: \1
Input: +15551234567
Expected: 5551234567
Actual: +15551234567 (unchanged)
Problem: + not properly escaped in pattern (some systems)
Fix: ^\\+1([0-9]{10})$ or ^\+1([0-9]{10})$ depending on system

Scenario 4: Replacement String Literal

Pattern: ^([0-9]{10})$
Replacement: "+1\1"
Input: 5551234567
Expected: +15551234567
Actual: "+1\1" (literally)
Problem: Some systems treat quoted strings as literals
Fix: Remove quotes: +1\1

Testing Fix:

1. Adjust replacement pattern
2. Test in pattern tester
3. Verify output correct
4. Make test call
5. Check CDR entry

Regex Dialect

Different PBX systems use different regex engines (PCRE, POSIX, etc.). Test on actual system, not just online regex testers.

Reformatting Breaks All Calls

Problem: After enabling rules, all calls fail

Emergency Fix:

1. Disable all reformatting rules immediately
2. Test call (should work now)
3. Re-enable rules one at a time to find culprit

Common Causes:

1. Overly Aggressive Pattern:

Rule: Replace all numbers with empty string
Pattern: .*
Replacement: (empty)
Result: All numbers deleted, routing fails

Fix: Remove or correct rule

2. Invalid Format to Provider:

Rule: Add + to all numbers
Provider: Doesn't accept + (expects national format)
Result: All outbound calls rejected

Fix: Check provider requirements, adjust rules

3. Strip Essential Digits:

Rule: Strip leading 1
Pattern: ^1(.*)$
Replacement: \1
Problem: Also strips 1 from middle of numbers (if not anchored correctly)
Result: Numbers corrupted

Fix: Use specific pattern: ^1([0-9]{10})$

4. Circular Transformation:

Rule 1: Add +1
Rule 2: Strip +1
Priority conflict: Loops infinitely
Result: System hangs or times out

Fix: Separate inbound vs outbound rules clearly

5. Regex Timeout:

Pattern: Complex regex with catastrophic backtracking
Result: Regex engine hangs, calls timeout

Fix: Simplify pattern, test performance

Recovery Steps:

  1. Disable all rules
  2. Export current rules for analysis
  3. Start with single simplest rule
  4. Test thoroughly
  5. Add rules one at a time, testing each
  6. Once all working, re-enable

Always Have Backup

Before deploying reformatting rules, export current configuration and document rollback procedure.

Slow Call Setup Due to Reformatting

Problem: Calls take long to connect after adding rules

Diagnostics:

1. Measure Rule Processing Time:

Without rules: 200ms call setup
With rules: 2000ms call setup
Difference: 1800ms from reformatting
Problem: Rules taking too long

2. Identify Slow Rules:

Test each rule individually:
Rule 1: +10ms
Rule 2: +15ms
Rule 3: +1500ms ← culprit
Rule 4: +10ms

Rule 3 has complex regex or inefficient pattern

3. Complex Regex Patterns:

Slow Pattern: ^([0-9]{0,20})*([0-9]{0,20})*([0-9]{0,20})*$
Problem: Catastrophic backtracking
Fast Pattern: ^[0-9]{1,20}$

4. Too Many Rules:

Problem: 50+ rules all processing for each call
Solution: Consolidate rules
Before: 50 separate rules for different patterns
After: 5 combined rules with alternation
Result: 10x faster

Optimization Strategies:

Combine Similar Patterns:

Before (3 rules):
  Rule 1: ^([0-9]{10})$
  Rule 2: ^([0-9]{11})$
  Rule 3: ^([0-9]{12})$

After (1 rule):
  Rule: ^([0-9]{10,12})$
Result: Process once instead of three times

Use Specific Patterns:

Slow: .*([0-9]+).*
Fast: ^[0-9]{10}$
Reason: Anchors prevent backtracking

Remove Unnecessary Rules:

Review: Do you really need all rules?
Remove: Obsolete rules for old provider
Remove: Display formatting rules if not used
Keep: Only essential transformation rules

Cache Results (if supported):

Feature: Cache reformatted numbers
Benefit: Same number reformatted multiple times uses cache
Result: Significant speedup for repeat callers

Performance Monitoring

Monitor call setup time metrics. If average increases after adding rules, optimize patterns or reduce rule count.


Next Steps