VoIP Mailing List Archives
Mailing list archives for the VoIP community |
|
View previous topic :: View next topic |
Author |
Message |
lardconcepts at gmail.com Guest
|
Posted: Thu Oct 13, 2016 5:55 am Post subject: [asterisk-users] Match one OR two digit extension not workin |
|
|
Back to basics here. I want to match on one OR two digits.
The following two both work, but ONLY for more than one digit, which
is not as expected from the docs (see below).
exten => _X.,1,SayNumber(${EXTEN})
exten => _[0-9].,1,SayNumber(${EXTEN})
This next one will ONLY match 2 digits, as expected, but the first two
SHOULD match one or more, right?
exten => _XX,1,SayNumber(${EXTEN})
The following pattern works, but I thought it was "dangerous" and to
be discouraged?
exten => _.,1,SayNumber(${EXTEN})
So, again, if someone dials 1 and a one second delay passes, I want it to say 1.
If someone dials 1 then another 1 within a second then I want it to be
11, and 111 should be invalid.
(I've Set(TIMEOUT(digit)=1) )
Yes, I can do this with multiple lines, but the docs suggest this
should be easily do-able in 1 line, and I don't want to double the
amount of dialplan (there'll be a few of these!).
Here are my references:
---------------------------------------------------
https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching
The letter X or x represents a single digit from 0 to 9.
The period character (.) at the end of a pattern matches one or more
remaining characters. You put it at the end of a pattern when you want
to match extensions of an indeterminate length.
---------------------------------------------------
Page 141 of the Asterisk Definitive Guide 4th Edition:
. (period)
Wildcard match; matches one or more characters, no matter what they are.
If you’re not careful, wildcard matches can make your dialplans do
things you’re not expecting (like matching built-in extensions such
as i or h). You should use the wildcard match in a pattern only after
you’ve matched as many other digits as possible. For example, the
following pattern match should probably never be used:
_.
In fact, Asterisk will warn you if you try to use it. Instead, if you
really need a catchall pattern match, use this one to match all strings
that start with a digit followed by one or more characters (see ! if
you want to be able to match on zero or more characters):
_X.
Or this one, to match any alphanumeric string:
_[0-9a-zA-Z].
---------------------------------------------------
http://www.voip-info.org/wiki/view/Asterisk+Dialplan+Patterns
Do not use a pattern of _. as this will match everything including
Asterisk special extensions like i, t, h, etc. Instead use something
like _X. or _X which will not match __special__ extensions..
So what do you use instead of _. ? Many examples use this construct,
but if you use it you may see a warning message in the log advising
you to change _. to _X.
---------------------------------------------------
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference
New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
jean.aunis at prescom.fr Guest
|
Posted: Thu Oct 13, 2016 6:05 am Post subject: [asterisk-users] Match one OR two digit extension not workin |
|
|
You can use the "!" character :
exten => _X!,1,SayNumber(${EXTEN})
Best regards
Jean Aunis
Le 13/10/2016 à 12:54, Jonathan H a écrit :
Quote: | Back to basics here. I want to match on one OR two digits.
The following two both work, but ONLY for more than one digit, which
is not as expected from the docs (see below).
exten => _X.,1,SayNumber(${EXTEN})
exten => _[0-9].,1,SayNumber(${EXTEN})
This next one will ONLY match 2 digits, as expected, but the first two
SHOULD match one or more, right?
exten => _XX,1,SayNumber(${EXTEN})
The following pattern works, but I thought it was "dangerous" and to
be discouraged?
exten => _.,1,SayNumber(${EXTEN})
So, again, if someone dials 1 and a one second delay passes, I want it to say 1.
If someone dials 1 then another 1 within a second then I want it to be
11, and 111 should be invalid.
(I've Set(TIMEOUT(digit)=1) )
Yes, I can do this with multiple lines, but the docs suggest this
should be easily do-able in 1 line, and I don't want to double the
amount of dialplan (there'll be a few of these!).
Here are my references:
---------------------------------------------------
https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching
The letter X or x represents a single digit from 0 to 9.
The period character (.) at the end of a pattern matches one or more
remaining characters. You put it at the end of a pattern when you want
to match extensions of an indeterminate length.
---------------------------------------------------
Page 141 of the Asterisk Definitive Guide 4th Edition:
. (period)
Wildcard match; matches one or more characters, no matter what they are.
If you’re not careful, wildcard matches can make your dialplans do
things you’re not expecting (like matching built-in extensions such
as i or h). You should use the wildcard match in a pattern only after
you’ve matched as many other digits as possible. For example, the
following pattern match should probably never be used:
_.
In fact, Asterisk will warn you if you try to use it. Instead, if you
really need a catchall pattern match, use this one to match all strings
that start with a digit followed by one or more characters (see ! if
you want to be able to match on zero or more characters):
_X.
Or this one, to match any alphanumeric string:
_[0-9a-zA-Z].
---------------------------------------------------
http://www.voip-info.org/wiki/view/Asterisk+Dialplan+Patterns
Do not use a pattern of _. as this will match everything including
Asterisk special extensions like i, t, h, etc. Instead use something
like _X. or _X which will not match __special__ extensions..
So what do you use instead of _. ? Many examples use this construct,
but if you use it you may see a warning message in the log advising
you to change _. to _X.
---------------------------------------------------
|
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference
New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
lardconcepts at gmail.com Guest
|
Posted: Thu Oct 13, 2016 6:10 am Post subject: [asterisk-users] Match one OR two digit extension not workin |
|
|
Sorry, I should have said, I already tried "!".
It matches immediately and doesn't wait for a second digit.
On 13 October 2016 at 12:05, Jean Aunis <jean.aunis@prescom.fr> wrote:
Quote: | You can use the "!" character :
exten => _X!,1,SayNumber(${EXTEN})
Best regards
Jean Aunis
Le 13/10/2016 à 12:54, Jonathan H a écrit :
Quote: |
Back to basics here. I want to match on one OR two digits.
The following two both work, but ONLY for more than one digit, which
is not as expected from the docs (see below).
exten => _X.,1,SayNumber(${EXTEN})
exten => _[0-9].,1,SayNumber(${EXTEN})
This next one will ONLY match 2 digits, as expected, but the first two
SHOULD match one or more, right?
exten => _XX,1,SayNumber(${EXTEN})
The following pattern works, but I thought it was "dangerous" and to
be discouraged?
exten => _.,1,SayNumber(${EXTEN})
So, again, if someone dials 1 and a one second delay passes, I want it to
say 1.
If someone dials 1 then another 1 within a second then I want it to be
11, and 111 should be invalid.
(I've Set(TIMEOUT(digit)=1) )
Yes, I can do this with multiple lines, but the docs suggest this
should be easily do-able in 1 line, and I don't want to double the
amount of dialplan (there'll be a few of these!).
Here are my references:
---------------------------------------------------
https://wiki.asterisk.org/wiki/display/AST/Pattern+Matching
The letter X or x represents a single digit from 0 to 9.
The period character (.) at the end of a pattern matches one or more
remaining characters. You put it at the end of a pattern when you want
to match extensions of an indeterminate length.
---------------------------------------------------
Page 141 of the Asterisk Definitive Guide 4th Edition:
. (period)
Wildcard match; matches one or more characters, no matter what they are.
If you’re not careful, wildcard matches can make your dialplans do
things you’re not expecting (like matching built-in extensions such
as i or h). You should use the wildcard match in a pattern only after
you’ve matched as many other digits as possible. For example, the
following pattern match should probably never be used:
_.
In fact, Asterisk will warn you if you try to use it. Instead, if you
really need a catchall pattern match, use this one to match all strings
that start with a digit followed by one or more characters (see ! if
you want to be able to match on zero or more characters):
_X.
Or this one, to match any alphanumeric string:
_[0-9a-zA-Z].
---------------------------------------------------
http://www.voip-info.org/wiki/view/Asterisk+Dialplan+Patterns
Do not use a pattern of _. as this will match everything including
Asterisk special extensions like i, t, h, etc. Instead use something
like _X. or _X which will not match __special__ extensions..
So what do you use instead of _. ? Many examples use this construct,
but if you use it you may see a warning message in the log advising
you to change _. to _X.
---------------------------------------------------
|
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference
New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users
|
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference
New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
tony at softins.co.uk Guest
|
Posted: Thu Oct 13, 2016 7:18 am Post subject: [asterisk-users] Match one OR two digit extension not workin |
|
|
In article <CAEebyNV+64CsK0N5+Jwn-c1qgt9ai7E-yMu_OaMayavGQ5tfOQ@mail.gmail.com>,
Jonathan H <lardconcepts@gmail.com> wrote:
Quote: | Back to basics here. I want to match on one OR two digits.
The following two both work, but ONLY for more than one digit, which
is not as expected from the docs (see below).
exten => _X.,1,SayNumber(${EXTEN})
exten => _[0-9].,1,SayNumber(${EXTEN})
This next one will ONLY match 2 digits, as expected, but the first two
SHOULD match one or more, right?
exten => _XX,1,SayNumber(${EXTEN})
The following pattern works, but I thought it was "dangerous" and to
be discouraged?
exten => _.,1,SayNumber(${EXTEN})
So, again, if someone dials 1 and a one second delay passes, I want it to say 1.
If someone dials 1 then another 1 within a second then I want it to be
11, and 111 should be invalid.
(I've Set(TIMEOUT(digit)=1) )
Yes, I can do this with multiple lines, but the docs suggest this
should be easily do-able in 1 line, and I don't want to double the
amount of dialplan (there'll be a few of these!).
|
When matching an extension being dialled, Asterisk is only concerned
about priority 1, so that's the only priority you need to double.
You should be able to use ! safely in priority 2 upwards:
exten => _X,1,NoOp(Matching single digit)
exten => _X.,1,NoOp(Matching multiple digits)
exten => _X!,2,SayNumber(${EXTEN})
exten => _X!,3,Etc..
Disclaimer: I haven't tested this.
Cheers
Tony
--
Tony Mountifield
Work: tony@softins.co.uk - http://www.softins.co.uk
Play: tony@mountifield.org - http://tony.mountifield.org
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference
New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
lardconcepts at gmail.com Guest
|
Posted: Fri Oct 14, 2016 7:56 am Post subject: [asterisk-users] Match one OR two digit extension not workin |
|
|
On 13 October 2016 at 13:18, Tony Mountifield <tony@softins.co.uk> wrote:
Quote: | exten => _X,1,NoOp(Matching single digit)
exten => _X.,1,NoOp(Matching multiple digits)
exten => _X!,2,SayNumber(${EXTEN})
exten => _X!,3,Etc..
|
Thanks - I appreciate the idea, but it matches more than 2 digits.
But, thanks to your info, I cobbled together something that works, and
matches only 1 or 2 digits in what I think is the most compact way, by
sending a 1 digit extension to the 2 digit matcher, prefixed with a 0.
Example which works:
[extentest]
exten => s,1,Set(TIMEOUT(digit)=1)
same => n,BackGround(extension)
same => n,WaitExten(5)
exten => _X,1,Goto(0${EXTEN},1)
exten => _XZ,1,SayNumber(${EXTEN})
same => n,Goto(s,1)
exten => e,1,Goto(s,1)
***HOWEVER!!!!*** Do I need to report a bug?
Either:
A: All the documentation is wrong and ". (period) Wildcard match;
matches one or more characters" is NOT actually how Asterisk works.
or
B: The documentation is correct and Asterisk's "one of more character
matching" routine is wrong
or
C: I've completely misunderstood what "matches one of more characters" means
What's the consensus? Thanks!
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference
New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
tony at softins.co.uk Guest
|
Posted: Fri Oct 14, 2016 8:54 am Post subject: [asterisk-users] Match one OR two digit extension not workin |
|
|
In article <CAEebyNX5JffKHFxwRJ3pSbG7YpeDLWweE=WjdmvwyzQySLSYag@mail.gmail.com>,
Jonathan H <lardconcepts@gmail.com> wrote:
Quote: | On 13 October 2016 at 13:18, Tony Mountifield <tony@softins.co.uk> wrote:
Quote: | exten => _X,1,NoOp(Matching single digit)
exten => _X.,1,NoOp(Matching multiple digits)
exten => _X!,2,SayNumber(${EXTEN})
exten => _X!,3,Etc..
|
Thanks - I appreciate the idea, but it matches more than 2 digits.
But, thanks to your info, I cobbled together something that works, and
matches only 1 or 2 digits in what I think is the most compact way, by
sending a 1 digit extension to the 2 digit matcher, prefixed with a 0.
Example which works:
[extentest]
exten => s,1,Set(TIMEOUT(digit)=1)
same => n,BackGround(extension)
same => n,WaitExten(5)
exten => _X,1,Goto(0${EXTEN},1)
exten => _XZ,1,SayNumber(${EXTEN})
same => n,Goto(s,1)
exten => e,1,Goto(s,1)
***HOWEVER!!!!*** Do I need to report a bug?
Either:
A: All the documentation is wrong and ". (period) Wildcard match;
matches one or more characters" is NOT actually how Asterisk works.
or
B: The documentation is correct and Asterisk's "one of more character
matching" routine is wrong
or
C: I've completely misunderstood what "matches one of more characters" means
What's the consensus? Thanks!
|
As I understand it, there are two different functionalities overloaded
on the operators.
1. The . in a pattern will match one or more digits, but only when
WaitExten has exited due to the digit timeout. Even if the number
being collected would match the ., it does not do so until Asterisk
decides no more digits will be entered.
2. The ! in a pattern will match zero or more digits, and will also
cause WaitExten to be satisfied as soon as it can match the pattern,
without waiting for more digits.
It's a pity that the choice between one-or-more and zero-or-more is
overloaded with wait-for-dialling-pause and match-immediately, rather
than being selectable independently. But it's been like that ever since
! was introduced, probably over 10 years ago.
Cheers
Tony
--
Tony Mountifield
Work: tony@softins.co.uk - http://www.softins.co.uk
Play: tony@mountifield.org - http://tony.mountifield.org
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
Join the Asterisk Community at the 13th AstriCon, September 27-29, 2016
http://www.asterisk.org/community/astricon-user-conference
New to Asterisk? Start here:
https://wiki.asterisk.org/wiki/display/AST/Getting+Started
asterisk-users mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-users |
|
Back to top |
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|