Dial Transform

From TTT
Jump to: navigation, search

Dial transform is used to change dialed numbers. With this feature enabled it is possible to change some frequently used characters in a phone number.

Contents

Adding transformations

The screen shot below shows the dial transform contains two key elements:

  • Table containing the transform rows
  • Buttons for manipulating the rows.

File:ScreenshotDialTransform.png

The table contains three columns. When the table only contains one row with both search and replace empty, the dial transform is inactive. To add a new row the empty row can be edited. A new blank row will be added beneath all other rows.

When the check box in the third column (might not exist in earlier versions) is unchecked the row acts as a normal row. This means this row will act as a simple search and replace. By checking the check box the row will act like a "Regular Expression"-row.

The order of the rows impacts the way search and replaces are done. The order is always top to bottom, which means that the first row will be performed on a incoming number before the second row (and so on). The blue buttons next to the table help arrange the rows. Select the row which need to be moved up or down than click button:

  1. to move the row to the top
  2. to move the row one up
  3. to move the row one down
  4. to move the row to the bottom

The 5th button can be used to load a template set of dial transformations.

The 6th button can delete highlighted rows.

Standard method row

The default method of search and replace will search the text specified in the "search"-column and replaces it with the text specified in the "replace"-column. If the search text is found multiple times every occurrence will be replaced by the replace text.

Examples

In general dutch phone numbers are specified like "+31 (0)20 1234567" or "(020) 12343567". ADAT will be able to convert this to a well-formed phone number using the following search and replace actions (In order of execution).

  • Search " " (space) -> Replace "" (nothing)
  • Search "+31(0)" -> Replace "0"
  • Search "+31" -> Replace "0"
  • Search "(0)" -> Replace "" (nothing)
  • Search "+" -> Replace "00"

This example starts by removing all spaces from the phone number. Next action is checking if this number is directed towards a dutch phone number (the local area for this example) and strip the international part. Since the correct method of specifying a dutch number is "+31 20 1234567" (omitting the zero before the 20) we also check for +31 alone. Change this to 0, to restore the dutch region number: "020". Remove "(0)" because this is optional in this number format. Finally change "+" for international numbers like +44 (United Kingdom) to 0044.

You are free to use any characters in both the search as the replace field. Please remind that this search system will not discriminate any character in the incoming dial string, this means if the search contains "1" f.e., every 1 in the dialed string will be replaced by the string in replace.

Regular Expressions row

Functionality added in version 0.7.7.2

To add more complicated search and replace actions the "Regular Expressions" option was added to the ADAT Dial Transform. Regular expressions resemble the normal search and replace rows and can be mixed together. The advantage of using regular expressions is the option to search for patterns in the dialed number.

To specify the search pattern using regular expressions a valid "Regular Expression" has to be specified. The specification ADAT understands is the ".NET RegEx"-format.

Examples

Two basic examples to show the power of regular expression:

Prefix dialed numbers

  • Search: "^" -> Replace: "1"

This expression looks for beginnings of a text by using "^". It replaces it with a 1 (since text beginnings can't literally be "replaced" the 1 is added to the beginning of a string.

When using this row the dialed number "500" will be changed to "1500".

End of a row is specified using "$"

Name trick

  • Search: "(\w+),\s(\w+)" -> Replace: "$2 $1"

Note: This example is not really used to convert a phone number to a dial-able number but to demonstrate pattern replacement.

With Regex found patterns can also be used in the replace. "\w" means stands for any character found, the plus makes the \w mean 1 or more times "any character" -> thus a word. This pattern is contained by round brackets. then a comma and "\s" is specified. This means the word is being followed by "," and some sort of white-space (space, tab, etc..). Then the pattern is finished with a second word. The brackets are numbered in order of occurence, the first (\w+) receives callsign "$1" and the second "$2". If more bracket sets are specified the number just continues ($3, $4, etc..).

When using "$2 $1" we can replace "Smith, John" to "John Smith".


Prefix dialed numbers (Only for longer numbers while ignoring short ones)

  • Search: "^([0-9]{7,15})$" -> Replace: "9$1"

When you want to have a phone number prefixed with a certain number, the best way to do this is by searching for a pattern that you'd like to be prefixed. In this example above, we search for the beginning of the number ("^") followed by a number between 0 and 9 (including the 0). appearing 7 to 15 times after each other ({7,15}) and then stopping.

The round brackets (we have 1 pair, so we can use $1) contain the 7 to 15 characters number we want to prefix. The "9$1", will indicate ADAT the number needs to be prefixed with a "9". Any other prefix will ofcourse also be able. for example: Prefix 8 = "8$1", Prefix 1 = "1$1", Prefix 13 = "13$1" and Prefix "Somethingcompletelydifferent" = "Somethingcompletelydifferent$1". As you see, the prefix doesn't have to be a number.

The size of the number to replace is determined by the {7,15} part. Only prefixing numbers of size 10 up to 15 numbers would be {10,15}. If everything longer than 7 characters should be prefixed you can use {7,} (Seven followed by a comma only). Only want to prefix numbers exactly 7 characters long? Use {7} (Don't use a comma). Placing the comma left of the number {,7} will select all numbers up to 7 characters long to be selected.

Personal tools