Extended Regular Expresion
ERE work on the header of the sip packet changing 01133508795@domain.com to 879@domain.com
for this example we will use the ERE string ![0-9]{7}([0-9]{3})!\1!
First I will explain how this is broken up.
- Question marks ! are used to separate the sections of the expresion
- Square Brackets [] are used to specify the characters to match
- Braces {} is the length of the numbers to match
- Parentheses () is used as storage it will store what it matches
- \1 calls the string that was captured inbetween the first set of Parentheses ()
So to breakdown the string ![0-9]{7}([0-9]{3})!\1! The question mark ! starts the expresion [0-9] any digit between 0-9 now {7} matches 7 digits these are not saved as there not in () the next section ([0-9]{3}) any digits between 0-9 and 3 characters this time it is stored as its in () we end the matching part of the string with the 2nd ! and now we want to send the call to an extension so we use \1 which calls the number that was stored in the expresion ([0-9]{3})
we have a DDI 01133508795 and we pass it through the expresion
! - start expresion
[0-9]{7} - 0113350 ignored
([0-9]{3}) - 879 stored as \1 as it’s the first stored
! - end pattern matching
\1 - we send the call to the first parren matced in () in our case 879
! - end expresion
Also * is a wildcard that means any length and any character (basicly anything) * could be 1321293127, asd123asd2, 1w etc
The $ signifys any character but only one so $= 1,2,3,a,3,b,2 etc can only be one character long similar to the x in the dial plan