How to block texts received from numbers that are longer than n digits? In South Africa, we are plagued with SMS spam, and it's practically impossible to get rid of it.

All the numbers that the spammers use are usually 13 or 14 digits - much longer than the standard 10 digits. 

(Click image to enlarge it)



The thinking behind this is that they cycle through literally millions of disposable numbers, so that if you block one of them, they'll still be able to spam you from all the others.

However, this thinking would then (hopefully) also be flawed. Surely there is a way to intercept an SMS, count the number of digits in the number and if it's longer than 12 (10 for the number, 2 for the country code), simply delete it, or even better add to blocked list.

Does anyone out there know of a way? I have Tasker, which I'm thinking is the way to go, but not sure where to start.
The first step to this would be detecting the length of the phone number.  

This can be done by passing %SMSRF to Test Variable > Type: Length. Test Variable can then output the phone number length as an integer which you can do checks on with an If.  

Once Tasker decides if the message is spam or not, you can then have it hide the notification, etc. (but not delete the message, as Tasker does not have this capability yet)