Page 1 of 1
Create Condition filter incoming_number with wildcards
Posted: 13 Feb 2014 08:12
by toonwolf
My goal is to create a flow that will reply with an sms when in a meeting. However if the incoming_number is starting with 715* and 675* (landline) then I would like the flow to stop. I tried to experiment with Expression "incoming_number=="715*", but that is not working. Can someone please help me with the correct syntax?
Re: Create Condition filter incoming_number with wildcards
Posted: 13 Feb 2014 17:40
by Martin
incoming_number=="715*" tests whether the number is exactly
715* (wildcards like * is not supported in strings like this).
You could use following script to test if a number starts with a prefix:
Code: Select all
startsWith(incoming_number, "715");
or using regular expressions:
Code: Select all
matches(incoming_number, "715.*");
Re: Create Condition filter incoming_number with wildcards
Posted: 13 Feb 2014 18:45
by toonwolf
Thank you for your reply. Is it possible to build an expression with more than one number?
Re: Create Condition filter incoming_number with wildcards
Posted: 13 Feb 2014 19:31
by Martin
You can combine multiple expressions with an or-operator, either
|| or
OR (both operators have the same meaning):
Code: Select all
startsWith(incoming_number, "715") || startsWith(incoming_number, "675");
respectively:
Code: Select all
startsWith(incoming_number, "715") OR startsWith(incoming_number, "675");
or with regular expressions:
Code: Select all
matches(incoming_number, "(715|675).*");
Re: Create Condition filter incoming_number with wildcards
Posted: 14 Feb 2014 05:56
by toonwolf
Thank you so much for your help. Tested and works like expected!
Re: Create Condition filter incoming_number with wildcards
Posted: 30 Dec 2017 05:06
by tphg
Martin wrote:You can combine multiple expressions with an or-operator, either
|| or
OR (both operators have the same meaning):
Code: Select all
startsWith(incoming_number, "715") || startsWith(incoming_number, "675");
respectively:
Code: Select all
startsWith(incoming_number, "715") OR startsWith(incoming_number, "675");
or with regular expressions:
Code: Select all
matches(incoming_number, "(715|675).*");
Thanks for your useful instruction.
But it failed to work when I add in area codes, e.g.
Code: Select all
matches(incoming_number, "(+22|+23).*");
Please advise how the correct expression syntax is in this case.
Thanks in advance.
Re: Create Condition filter incoming_number with wildcards
Posted: 30 Dec 2017 06:14
by Desmanto
tphg wrote:
Thanks for your useful instruction.
But it failed to work when I add in area codes, e.g.
Code: Select all
matches(incoming_number, "(+22|+23).*");
Please advise how the correct expression syntax is in this case.
Thanks in advance.
+ has special meaning in regex, it must be escaped using backslash. Since automagic backslash is a special character too, it must be escaped too with another backslash. So it should be.
Code: Select all
matches(incoming_number, "(\\+22|\\+23).*");
You can always try the regex using the built-in regex tester. When you put the regex without the backslash, it will show you syntax error. Anytime you deal with symbol and you encounter the syntax error, most likely you need to escape it using backslash.
Re: Create Condition filter incoming_number with wildcards
Posted: 30 Dec 2017 08:09
by tphg
Oh, it works like a charm.
Thank you @desmanto, and wishing you a Happy New Year!
-----------------------------------
P/S: Please have a look on my recent post on "SMS blocker based on keyword" at your convenience. I think you could help me.