LogoLogo
  • What is Itgrix
  • Contacts
  • Our story
  • Connector installation
    • System requirements
    • Itgrix for Bitrix24 and Asterisk
      • How to perform offline authorization
      • How to obtain a license offline
      • Configuring the connector to work in a closed network
      • Call tests
    • Itgrix for Kommo and Asterisk
      • Restricted mode setting features
      • Call card
      • Call tests
  • Additional functions
    • Automatic call transfer to responsible manager
    • Setting up click-to-call features
      • Features of customization after Bitrix24 23.300.0 update
    • Autoreplacement for phone numbers
    • How to view employee call statistics in Bx24
    • FMC number recognition
    • Configuring WebRTC in Asterisk (FreePBX)
    • Itgrix AsterPhone for Bitrix24
    • Itgrix AsterPhone for Kommo
  • For admins
    • Running an additional copy of the module
    • Deploying a module backup
    • Call processing for the period
    • Examples of the structure of registered calls from CEL
    • Wrong time in created cases in Bitrix24
    • SSH access
    • Useful commands
    • Script to test the module service
    • Changing login and password to enter the admin panel
    • Module files
    • Status monitoring
    • Application update
    • In the CEL table, there is no internal employee number in the cid_num column
    • How to fix click-to-call
    • Custom SSL certificates for https requests
    • Examples of configuring WSS connections
    • Converting recordings to MP3 before sending to Bitrix24
    • How to fix call recording problems
    • Install and configure CEL
    • B24 authorization bugfix
  • Useful customizations (any CRM)
    • Audio file name customization
    • Call data (call_full) in customizations
    • Change the number / context for calling to asterisk
    • Change phone number before sending data to CRM
    • Black and white lists
  • Useful customizations itgrix_bx (Bitrix24)
  • Useful customizations itgrix_kmo (Kommo)
  • FAQ
    • How to pay
    • How to check licence status
    • Differences in connection to B24 via SIP-connector and Itgrix
    • How to turn off the display of calls in the calendar
    • How to view statistics on employee calls
    • Updating the app
    • Offline install (only for Bitrix24)
    • Offline update
    • Reliable softphones for Asterisk
    • Detail-call-statuses
  • Changelog Itgrix_bx
  • Changelog Itgrix_kommo
  • Policy of interaction with Asterisk
Powered by GitBook
On this page
  • Regular expressions
  • Shortlist of useful pattern elements
  • Examples of autoreplacement for client numbers
  • Examples of autoreplacement for user numbers

Was this helpful?

  1. Additional functions

Autoreplacement for phone numbers

PreviousFeatures of customization after Bitrix24 23.300.0 updateNextHow to view employee call statistics in Bx24

Last updated 10 months ago

Was this helpful?

There are many possible ways to write the same phone number. 81234567890, +71234567890, 1234567890 and 8 (123) 456-78-90 are only a few obvious formatting examples. If you are getting calls from multiple countries, the number of options may be very high. For a human, those options are not very different. All of them will work if you dial them on the phone; it's easy to compare them and understand that they are the same number. However, for software, they are completely different numbers. For example, if you have a contact saved in CRM with a number starting with +7, but you type the same number in the search with 8 instead, then the search may not show this contact.

We used to only have number formatting in customizations to solve this problem. Now we've added an autoreplacement function in Itgrix bx and Itgrix amo . It allows to configure number formatting using regular expressions (regexp) right from the admin panel.

  1. Autoreplacement modifies client and/or user phone numbers that match templates by replacing whole numbers or their parts with substitutions. Multiple replacement patterns can be configured simultaneously.

  2. Replacements are executed before requests are sent to CRM, so autoreplacement affects the creation and search of entities, tasks, and users.

  3. All replacements are executed for each number one by one in turns. It means that the order of replacements is important, as the execution of the first replacement may make the number match or not match the following templates.

Regular expressions

We use the language of regular expressions (regexp) to describe the rules of autoreplacement, the same as we used to do before in customizations. This is a commonly used way of matching and modifying text.

Shortlist of useful pattern elements

Symbols

  • ^ - beginning of a line

  • $ - end of a line

  • . - any symbol

  • \d - a digit

  • \D - not a digit

  • \w - a digit or a letter

  • \W - not a digit and not a letter

  • \s - space (including unusual varieties, such as no-line-break spaces)

  • \S - not a space

  • [ab\s0-5] - either: a, b, space or digit between 0 and 5

  • abc 123 - literally "abc 123", possibly as a part of bigger text fragment

  • abc|123 - either "abc" or "123", possibly as a part of bigger text fragment

  • ^abc 123$ - "abc 123" as a whole line without additional text before or after

  • \(, \), \[, \], \{, \}, \+, \?, \*, \., \|, \\ - literal representation of symbols that have special meaninng when not preceeded by \

Repetitions

You can specify how many times a symbol or a group can be repeated by adding of the the following immediately after.

  • ? - 0 or 1 time

  • + - 1 or more times

  • * - any number of times (even zero)

  • {5} - 5 times

  • {5,10} - 5 to 10 times

  • {,10} - 0 to 10 times

  • {5,} - 5 or more times

For example, \d{10} means "ten digits", \+? means "plus sign, zero or one time" and 0+ means "one or more zeroes".

Groups and substitutions

Symbols can be combined into groups using brackets. This is useful for repeating multiple symbols. For example, (10){3} means "101010". Text from groups can be used in substitutions as $N where N is the number of a group. For example, when using a pattern 8(\d{6})(\d{4}), the substitution $1 would mean the contents of the group (\d{6}) - the first 6 digits after "8". The substitution $2 would mean the contents of the group (\d{4}) - the following 4 digits.

Examples of autoreplacement for client numbers

Pattern
Substitution
Description

^\+?7(\d{10})$

8$1

Replaces prefixes +7 and 7 in the beginning of a number that consists of a prefix followed by 10 digits with 8, e.g. +74951234567 → 84951234567 and 74951234567 → 84951234567 This pattern is enabled by default

^\+7

8

Replaces +7 in the beginning of any number with 8, e.g. +712345671234567 → 812345671234567

.*(\d{10})$

8$1

Replaces a number with 10 in the end with 8 and those 10 digits, e.g. 0071234567890 → 81234567890

^(\d{7})$

8495$1

Adds a prefix 8495 to a 7-digit number, e.g. 1234567 → 84951234567

\D

(empty string)

Removes all symbold except digits, e.g. +7 (495) 123-45-67 → 74951234567

[\s()-]

(empty string)

Removes all spaces, brackets and dashes, e.g. +7 (495) 123-45-67 → +74951234567

^(.*)(\d{3})(\d{3})(\d{2})(\d{2})$

$1 ($2) $3-$4-$5

Formats a number as x (xxx) xxx-xx-xx, e.g. +74951234567 → +7 (495) 123-45-67

^0\d{2}(\d+)$

8$1

Replaces a number composed of "zero, two digits, more digits" with 8 and the digits from the end of a number, e.g. 0771234567890123 → 81234567890123

1234567$

7654321

Replaces 1234567 in the end of a number with 7654321, e.g. 84951234567 → 84957654321

^84951234567$

84957654321

Replaces a literal number 84951234567 with 84957654321

Examples of autoreplacement for user numbers

Pattern
Substitution
Description

.*(\d{4}$)

$1

Removes everything except the last 4 digits, e.g. +71234564321 → 4321

^8123456(\d{4})$

$1

Removes a prefix 8123456, leaving last 4 digits, e.g. 849576543214321 → 4321

.*123456(\d{4})$

$1

Removes everything except the last 4 digits from a number ending with 123456 and 4 more digits, e.g. +71234564321 → 4321

^1\d{3}$

2$1

Replaces the first digit 1 of a 4-digit number with 2, e.g. 1234 → 2234

^1234$

4321

Replaces literal number 1234 with 4321

To create and test regular expressions, we suggest using online tools, such as (choose Golang in the left menu and lower choose Substitution to test replacements).

regex101.com
v2.10.0
v3.7.0