Validate digits script help

Hi

I have written a custom dial plan for setting an immediate forward to give us more control and extra features however I am struggling to add in some validation checks.

In the early stages I found that people were forwarding to non-existant numbers. I therefore added a LEN line to check that they have entered a minimum of 4 digits. However the problem still remains of people entering nonexistent numbers.

My system is cross platform so ideally, all I am trying to do is have a validation check that checks to see that what they have entered starts with either a 4, 5, 7 or 9 and ideally is either 4 or 12 digits long (not less than 4 and not inbetween 4 and 12).

I’ve been struggling with this for a few weeks but not getting anywhere

Can anyone advise?

Thanks

You could do it with regular expressions, assuming that asterisk supports extended regular expressions, or you could use extension pattern matching, in a subroutine.

Going along the lines of checking whether it starts with 4, 5 or 7 I have tried this but it always returns 0

exten => s,n,GotoIf($[${REGEX(“4-7” ${toext:0:1})}]?externalcheck:intlengthchk)

I know 6 is covered in that but not sure how to just include 4, 5, 7

If I enter 5000 it returns 0 where I would have thought it would have returned a 1

Sussed, it

I was missing [] around the 4-7 (as well as still requiring “”)