Create Condition filter incoming_number with wildcards
Moderator: Martin
Create Condition filter incoming_number with wildcards
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
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:
or using regular expressions:
You could use following script to test if a number starts with a prefix:
Code: Select all
startsWith(incoming_number, "715");
Code: Select all
matches(incoming_number, "715.*");
Re: Create Condition filter incoming_number with wildcards
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
You can combine multiple expressions with an or-operator, either || or OR (both operators have the same meaning):
respectively:
or with regular expressions:
Code: Select all
startsWith(incoming_number, "715") || startsWith(incoming_number, "675");
Code: Select all
startsWith(incoming_number, "715") OR startsWith(incoming_number, "675");
Code: Select all
matches(incoming_number, "(715|675).*");
Re: Create Condition filter incoming_number with wildcards
Thank you so much for your help. Tested and works like expected!
Re: Create Condition filter incoming_number with wildcards
Thanks for your useful instruction.Martin wrote:You can combine multiple expressions with an or-operator, either || or OR (both operators have the same meaning):respectively:Code: Select all
startsWith(incoming_number, "715") || startsWith(incoming_number, "675");
or with regular expressions:Code: Select all
startsWith(incoming_number, "715") OR startsWith(incoming_number, "675");
Code: Select all
matches(incoming_number, "(715|675).*");
But it failed to work when I add in area codes, e.g.
Code: Select all
matches(incoming_number, "(+22|+23).*");
Thanks in advance.
Re: Create Condition filter incoming_number with wildcards
+ 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.tphg wrote: Thanks for your useful instruction.
But it failed to work when I add in area codes, e.g.Please advise how the correct expression syntax is in this case.Code: Select all
matches(incoming_number, "(+22|+23).*");
Thanks in advance.
Code: Select all
matches(incoming_number, "(\\+22|\\+23).*");
Index of Automagic useful thread List of my other useful posts (and others')
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Xiaomi Redmi Note 5 (whyred), AOSP Extended v6.7 build 20200310 Official, Android Pie 9.0, Rooted.
Re: Create Condition filter incoming_number with wildcards
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.
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.