Fill a capturing group without capturing

Hi guys,

i’m usung regex withing microsoft teams for number normalization.

I want to add a prefex in case of a dial string.

for example:

Input:
*1456

Match:
^*1(d{3})$

Replace *1 with the prefix 123:
123$1

Output:
123456

kk, that’s eays, but every prefix consumes a own rule. If I want tu replace *2 with the prefix 234, i need another rule.

But now i want to fill the prefix within group. The next step should be to handle serveral prefixes within one regex to optimize my dial plan.

I tried the follwing:

Input:
*1456

Match:
^*1(123)?(d{3})

Replace *1 with the prefix 123:
$1$2

The input match the condition, the the first capturing group ($1) is empty.
So what i want is to insert the prefix 123, witch is no included in the input, into a group.

I dont’t know if this is possible.

Thx

Sascha

Read more here: Source link