Regular expression for caller_id_name

Status
Not open for further replies.

goose2600

Member
Dec 18, 2018
51
1
8
Hi to all, I am playing with cidlookcup.
I put this in dialplan (order 99):
caller_id_name=${cidlookup(${caller_id_number})}

It works (looking in fusionpbx contacts and from external sources), but if the caller_id_number is unknown, of course it show UNKNOWN as caller_id_name.

In case of unknown callers, I would like to set effective_caller_id_name to caller_id_number (effective_caller_id_name=${caller_id_number}).
So, I created a dialplan rule to manage the caller name rewriting, but I dont know the right regular expression to put in the condition field in dialplan.
I tried things like (UNKNOWN) and other regex without success.
If I use regex (\w+), it works but, of course, matches any word, while I need to match only the names that containing the word UNKNOWN.

Can someone help me?
Thanks.


Edit: I reached my goal by changing the cidlookup answer, but I am still interested in understanding how regex works in fusionpbx.
 
Last edited:

goose2600

Member
Dec 18, 2018
51
1
8
@agree , thanks for replying.
Before to write my post I made some test anche I checked out on regex101

If I use a "full" regex, it works:
caller_id_name: 0612345678
regex: (0612345678)

Usually, after a cidlookup the caller_id_name looks like this:
0612345678(X)
Where X is the "spam score", from 1 to 9, I woluld like to match.
caller_id_name: 0612345678(9)
regex: (\(9\))
This not works.

EDIT
Looks like my issue is not related to regex.
Maybe it is related to the way I use cidlookup:
dialplan_manger.jpg

If the original caller_id was 0612345678, after the cidlookcup it become: effective_caller_id_name=0612345678(9)
The issue is that I can match only with the original caller_id, not the number between the brackets.
 
Last edited:
Status
Not open for further replies.