The example scenario uses a regex string to match any 3-digit number that begins with a 2. It does that to match any internal extension numbers on the IP Office system.
The regex string used was: ^\+?(2\d{2})$
The string works as follows:
-
The ^ matches the start of the string.
-
The \+? is an optional match:
-
The \+ matches a literal + character (the E.164 international prefix indicator). The string needs a \ as a + on its own is a regex command.
-
The ? modifies the preceding \+ to mean match if the + is present or not.
-
The ( ) brackets group elements.
-
The brackets contain 2\d{2}:
-
The 2 matches a 2 at the start of the number.
-
The \d matches any digit. The string needs a \ as a d is the regex to match an alphabetic d.
-
The {2} modifies the preceding \d to match 2 instances of that element.
-
Therefore, \d{2} matches any two digits.
-
The $ matches the end of the string. Including this means the pattern will not match longer numbers that begin with a 2.