Need help with REGEX

I am new with Asterisk, but have done over 30 years of telephony and software programming: QBasic to VB6 (some .net)

I have been successful in understanding a lot of the language in the Dial Plan, but need some help with REGEX.

I have search the internet (with no luck) trying to understand the following:

I know that the expression here says: Look in the ${ARG1} variable and see if it matches the pattern “^[0-9] {3,3}” and if there is a match, set anurisum = 1. If not, anurisum = 0

I need help with the {3,3} in peticular

Here are some test I made tring to understand how the {x,x} works
[0-9] {3,3} matches any digits of 3 or more.
[0-9] {3,4} matches any digits of 3 or more.
[0-9] {3,4} matches any digits of 3 or more.
[0-9] {3,6} matches any digits of 3 to more. (what is the digit 6 suppose to do here?)
(Why are all these expresions doing the same thing?)

[0-9] {3,3} fails
[9-0] {4,4} fails \ anurisum = “” (empty string) or NULL (can’t tell)
[9-0] {3,2} fails /
[9-0] {4,} fails /

[0-9] {3} matches any digits 3 or more (what gives?). Should {3} mean only 3 digits?

Please direct me to a web site or please explain how the {x,x} and {x,x} are suppose to work.


The intended behaviour will be as in:

man 7 regex

It uses the standard Unix regular expression library, so should do that rather well.

The \ is almost certainly there to protect characters that are significant to the extensions.conf parser, not as part of the regular expression.

Asterisk will substitute variables before it tries to parse the expression.

The expressions are doing the same thing because they are not anchored on the right hand side.

Thanks for the info.