BLOCK any non-numeric number:
$ python /home/ssp/sippy/re_test.py 's/^.*[a-zA-Z].*$/BLOCK/' B1231231236016 Result: BLOCK |
Add special prefix if the incoming number's length is 10digits:
python /home/ssp/sippy/re_test.py 's/^([0-9]{10,10})$/#1\1/;' 1234567890 Result: #11234567890 or python /home/ssp/sippy/re_test.py 's/^(\d{10}$)/90312\1/;' 1234567890 Result: 903121234567890 or python /home/ssp/sippy/re_test.py 's/^(..........)$/1\1/' 1234567890 Result: 11234567890 |
Double action:
if an 11digits number comes into the Sippy Softswitch with the prefix 0 and which has 10 digits after the 0, we want to convert this 0 to 90 and process the call as usual then:
python /home/ssp/sippy/re_test.py 's/^0(\d{10}$)/90\1/' 01234567890 Result: 901234567890 |
Add prefix 1 for any sequence of 10 symbols:
python /home/ssp/sippy/re_test.py 's/^(.{10})$/1\1/' 209876543a Result: 1209876543a |
Add + if it's not already present:
python /home/ssp/sippy/re_test.py 's/^([a-zA-Z_0-9])/+\1/;' 1223445512234455 Result: +1223445512234455 |
Exclude + from the prefix
python /home/ssp/sippy/re_test.py 's/^\+//;' +1223445512234455 Result: 1223445512234455 or s/^'[+]'// or s/^[+]// |
Custom case - replace only +1 with 1:
python /home/ssp/sippy/re_test.py 's/^\+1/1/' +123456789 Result: 123456789 |
Custom case - convert +570 at the beginning of the number to 2222:
python /home/ssp/sippy/re_test.py 's/^[+]570/2222/' +570123456789 Result:2222123456789 |
In case of alphabetic as a cli we want to send 1909 CLI .in case of number CLI , it should be passed on as it is.
python /home/ssp/sippy/re_test.py 's/^.*[a-zA-Z].*$/1909/' anonymous Result: 1909 or python /home/ssp/sippy/re_test.py 's/.*[^0-9].*/44444/' anonymous Result: 44444 |
Case you need to add the prefix to alphanumeric CLI use below rule
$ python /home/ssp/sippy/re_test.py 's/^(.*[a-zA-Z].*)$/123\1/' anonymous Result: 123anonymous |
Suppose if the CLI is a five-digit numeric value(like 34565), I like to change it to 3456534565. I mean repeat this CLI two times:
$ python /home/ssp/sippy/re_test.py 's/^(.*)$/\1\1/' 34565 Result: 3456534565 |
I want to change the CLI to 123456 if there is no CLI coming from the account's call.
$ python /home/ssp/sippy/re_test.py 's/^$/123456/' Result: 123456 |
You can also check this command from the console by running the double translation:
first - to an empty string, second - from empty to the needed one:
$ python /home/ssp/sippy/re_test.py 's/^[a-zA-Z_0-9]*//;s/^$/123456/' 1sdf Result: 123456 |
Replace prefix 44 with 222 then replace the resulting 2222 prefix with 55
python /home/ssp/sippy/re_test.py 's/^44/222/;s/^2222/55/' 442333222111 Result: 55333222111 |
Please note, the second SippySoftswitch applies rules one by one, and after the first translation system applies the second translation sequently.
We need to make a 10 digit CLI if the CLI sent by the customer is equal to or less than 8 digits.
$ python /home/ssp/sippy/re_test.py 's/^([0-9]{8,8})$/30\1/;' 12345678 Result: 3012345678 |
If CLI is one digit (e.g. X), then the resulting CLI will be 303333333X
$ python /home/ssp/sippy/re_test.py 's/^([0-9])$/303333333\1/;' 4 Result: 3033333334 or $ python /home/ssp/sippy/re_test.py 's/^(\d)$/303333333\1/;' 5 Result: 3033333335 |
If CLI is two-digit (e.g. XX), then the resulting CLI will be 30333333XX
$ python /home/ssp/sippy/re_test.py 's/^([0-9]{2,2})$/30333333\1/;' 52 Result: 3033333352 |
If CLI is eight-digit (e.g. XXXXXXXX), than the resulting CLI will be 30XXXXXXXX.
$ python /home/ssp/sippy/re_test.py 's/^([0-9]{8,8})$/30\1/;' 12345678 Result: 3012345678 |
If CLI is hello, I want to make it Blank. Or also good to replace with '123456789*'
python /home/ssp/sippy/re_test.py 's/[a-zA-Z]//g;s/^$/Blank/' hello123 Result: 123 $python /home/ssp/sippy/re_test.py 's/[a-zA-Z]//g;s/^$/Blank/' hello Result: Blank |
Please note, the second rule is applied to a result of applying the first rule.
When a user dials the last 4 digits, like 6016, Sippy Softswitch shall translate it to 01548286016.
$ python /home/ssp/sippy/re_test.py 's/^(....)$/0164828\1/' 6016 Result: 01648286016 |
Translate all non 10 digits CLIs into the CLI of my choice, but pass through all CLIs with another length
$ python /home/ssp/sippy/re_test.py 's/^.{0,9}$/0123456789/' 6016123456 Result: 6016123456 $ python /home/ssp/sippy/re_test.py 's/^.{0,9}$/0123456789/' 601612345 Result: 0123456789 where 0123456789 is the CLI that you want to use as replaced |
CLI that ends with 1234 should be translated to an unknown number.
$ python /home/ssp/sippy/re_test.py 's/^.*1234$/unknown/' 60161231234 Result: unknown |
This rule adds 1122 to every number that matches the following:
I need this rule only to be applied only to CLDs that starts with "90 + any_3_digit number + 112". I can match the CLD with the rule '^90\d{3}112$' but I can not add 1122 to the end. $python /home/ssp/sippy/re_test.py 's/(?P<tr_gr>^90[0-9][0-9][0-9]112$)/\g<tr_gr>1122/' 90666112 Result: 906661121122 |
Add 011 prefix if the number starts from digit, do nothing if the number starts with +
$ python /home/ssp/sippy/re_test.py 's/^/011/;s/^011\+1/+1/' +13058946105 Result: +13058946105 $ python /home/ssp/sippy/re_test.py 's/^/011/;s/^011\+1/+1/' 13058946105 Result: 01113058946105 |
Add 90212 prefix for the following case:
the incoming number is being checked for matching the following rule:
from the end of the number this sequence is checked:
The last 6 symbols should be digits from 0 to 9, 7. The symbol from the end should be a digit from 1 to 8. Everything from the left of this sequence is being replaced with 90212 prefix, everything from the right is kept as is.
$python /home/ssp/sippy/re_test.py 's/.*([1-8]{1}[0-9]{6})/90212\1/' 1234567890123 Result: 902127890123 $python /home/ssp/sippy/re_test.py 's/.*([1-8]{1}[0-9]{6})/90212\1/' 123456789012a3 Result: 902126789012a3 |
A simpler example of this rule:
$ python /home/ssp/sippy/re_test.py 's/.*([0-9]{7})/90212\1/;' 12067773456 Result: 902127773456 |
Remove first 5digits from number, numbers with length <5 digits won't be converted as well as the letters
$ python /home/ssp/sippy/re_test.py 's/^[0-9]{5}//' 666667 Result: 7 |
Leave only the first 7 symbols of any numeric CLI
$ python /home/ssp/sippy/re_test.py 's/([0-9]{7}).*/\1/' 1234567890 Result: 1234567 |
If dialed 56789 number it should be translated to 5*75016789, same is for all digits from 1 to 32
python /home/ssp/sippy/re_test.py 's/(?P<tr_gr>^(3[0-2]|[12][0-9]|[1-9]))/\g<tr_gr>*7051/' 6911111 Result: 6*7051911111 |
Replace suffix 1110 to 1400*
python /home/ssp/sippy/re_test.py 's/1110$/1400/;' 1234561110 Result: 1234561400 |
Add 0000 suffix in case the number is 7 digits long :
$ python /home/ssp/sippy/re_test.py 's/^([0-9]{7})$/\1\060000/' 1234567 Result: 12345670000 |
whereas '\060' is 'zero code' presented in octal value.
If there is a 011 in front then strip it
OR
If there is a 1 in front don't do anything
If there is neither of 011 or 1 in front then add 1 in front of any number.
$ python /home/ssp/sippy/re_test.py 's/^/a1/;s/^a1011//;s/^a11/1/;s/^a//' 0112011555 Results 2011555 |
- pass only 12 digit numbers, all other numbers should be blocked *
s/^(.{0,11}|.{13,})$/non-rout/ |
- Translate 111 number to 222 and 222 to 111 in a single connection/account
All CLD translation rules will be applied one after another if specified in one connection.
Sippy received the number 00880NNN, translated it to 880NNN using rule s/^008801/8801/;
and after that number was translated a second time with the rule s/^8801/228801/;
We suggest the following construction:
Add 3 translation rules, in that case it would be
s/^008801/#8801/; s/^8801/228801/; s/^#8801/8801/; |
1 - incoming 00880NNN number is translated to another number with some tech prefix (# in our case) by rule s/^008801/#8801/;
2 - rule s/^8801/228801/;
is not applied to the result of first translation because of tech. prefix #
3 - #8801NNN
number is being translated to 8801NNN by the last rule s/^#8801/8801/;
Please note that order of translation rules is important.
- Remove non-digit characters from incoming CLI and CLD with CLI/CLD rules
's/\D//g' |
\D
Matches any non-digit character; this is equivalent to the class TrRules
- Remove dots from the number
$ python /home/ssp/sippy/re_test.py 's/\.//g' 1233.B003..ss123455s123123321 Result: 1233B003ss123455s123123321 |
How to correct incoming CLI from +90 (310) 988 00 00 to 903109880000:
$ python /home/ssp/sippy/re_test.py 's/^[+]//;s/[(]//;s/[)]//;s/\s+//g;' +90 (310) 988 00 00 Result: 903109880000 |
Please note, if you have spaces in your number then you have to use this number in ' '(quotes) to be able to run re_test.py without issues.
Calls via DID could be replaced by rules which you have specified in the account properties. So the main idea is to leave the original number in case of a call via DID and replace the number if call from Account.
$ python /home/ssp/sippy/re_test.py 's/^(\d).*/111/;s/^'[+]'//' +1234567 Result: 1234567 $ sudo python /home/ssp/sippy/re_test.py 's/^(\d).*/111/;s/^'[+]'//' 1234567 Result: 111 |
*How to truncate only 00 and to avoid truncating of 000: *
$ sudo python /home/ssp/sippy/re_test.py 's/^00([^0])/\1/' 000850532166 Result: 000850532166 $ sudo python /home/ssp/sippy/re_test.py 's/^00([^0])/\1/' 00850532166 Result: 850532166 $ sudo python /home/ssp/sippy/re_test.py 's/^00([^0])/\1/' 0850532166 Result: 0850532166 |
Convert to the Random number
Replace the original value with 5 random characters each of which can be 0, 1, 2, 3 and 6:
s/.*/${R:[0-3,6]5}/ |
Get the translated number with some constant prefix and the body with the numbers from some range:
prefix +17266
body - any number from 00000001 to 99999999
s/.*/+17266${R:[0-9]7[1-9]}/ |
if ANI length less than 6 (numbers or letters doesn't matter) then the rule is applied
If less or equel to 6 symbols: $ python /home/ssp/sippy/re_test.py 's/^([a-zA-Z_0-9]{1,6})$/test/' 123456 Result: test If longer than 6 symbols: $ python /home/ssp/sippy/re_test.py 's/^([a-zA-Z_0-9]{1,6})$/test/' 1234567 Result: 1234567 $ python /home/ssp/sippy/re_test.py 's/^([a-zA-Z_0-9]{1,6})$/test/;' abcdeg Result: test $ python /home/ssp/sippy/re_test.py 's/^([a-zA-Z_0-9]{1,6})$/test/;' abcdegf Result: abcdegf |
- If CLI is like 903121111111 or 903122222222 or 903123333333 pass CLI else Show CLI as 903121111111
$ python /home/ssp/sippy/re_test.py 's/^((?!(90312(1111111|2222222|3333333))).)*$/903121111111/' 903121111111 Result: 903121111111 |
- Strip '90' from the CLD number only in case it starts with 'BXXX' prefix, but the prefix should be retained *
$ python /home/ssp/sippy/re_test.py 's/^(B...)90/\1/' B0439012345678 B04312345678 |
- All CLI should be removed except for those that begin with 78565
$ python /home/ssp/sippy/re_test.py 's/^(?!78565).*//' 785650000 Result: 785650000 $ python /home/ssp/sippy/re_test.py 's/^(?!78565).*//' 1785650000 | sed 's/^/EMPTY_LINE/' EMPTY_LINE |
- How can I cut the 592 off for 7 digital numbers
$ python /home/ssp/sippy/re_test.py 's/^(592)([0-9]{4})$/\2/;s/^(592)([0-9]{7})$/\2/' 5929999 Results: 9999 |
- How can I cut the first digit in case if incoming CLI/CLD has 11 digits '''
$ python /home/ssp/sippy/re_test.py 's/^([0-9]{11,11})$/#\1/;s/^[#][0-9]{1,1}//;' 01234567890 Result: 1234567890 |
- How can I make CLI translation rule to change it from 00#91 , 028#91 & other #91 CLI's to some fixed CLI like 3444:
$ python /home/ssp/sippy/re_test.py 's/^.*[#]91.*/3444/;' 124a8#9112555615 Result: 3444 |
- How can I make CLI translation rule to change it from any number to following:
57300
57301
57302
57303
57304
5730557310
57311
57312
57313
57314
57315
57316
57317
57318
5731957320
57321
57322I would be wonderful if we could come to a working rule for all of these, the numbers itself consist
57 3XX + 7digits (random 0-9)
$ python /home/ssp/sippy/re_test.py 's/.*/573${R:[0,1,2]}/; s/^.*0$/5730${R:[0-5]}/; s/^.*1$/5731${R:[0-9]}/; s/^.*2$/5732${R:[0-2]}/; s/$/${R:[0-9]7}/;' 111 Result: 573208196684 |
- IF the CLI starts with 962 i want the the vendor connection to pass it as is.
IF any other CLI received i want it to be translated to 96268009996
s/^962/ZYX962/;s/^[0-9].*/96268009996/;s/^ZYX// |
- Remove CLI completely, no matter what value it had:
s/^.*// |
- Remove prefix 1, leave next 4 digits and add 6 random:
python /home/ssp/sippy/re_test.py 's/^1//;s/^([0-9][0-9][0-9][0-9]).*$/\1/;s/$/${R:[1-9]1[0-9]4[1-9]1}/;' 120264765752026912925 |
- Append a suffix to any number:
python /home/ssp/sippy/re_test.py 's/$/123/g' 120264765 Result: 120264765123 |