[asterisk-dev] Better pattern matching
Clive Nicolson
clive at baby.bedroom.gen.nz
Wed Aug 1 22:08:33 CDT 2007
On Wed, 1 Aug 2007, Clod Patry wrote:
> you probably are searching for RFC 2705 ?
>
> That would be great if Asterisk could support that kind of
> digitmaps/patterns.
>
>
Hi,
I have some code which roughly translates rfc 2705 digitmaps into a posix
extended regexpression:
The DigitMap is translated to a posix extended regexpression. The dialplan
regexression is then placed between ^( and )$ so that is is anchored at both
ends. The DigitMap is case insensitive. A posix_extended_regexpression is
case sensitive.
dialplan syntax in YACC/Bison format:
dialplan : 0:DigitMap
| 1:posix_extended_regexpression
;
DigitMap : DigitStringT
| '(' DigitStringTList ')'
;
DigitStringTList: DigitStringT
| DigitStringT '|' DigitStringTList
;
DigitStringT : DigitString
| DigitString 't'
;
DigitString : DigitStringElement
| DigitString DigitStringElement
;
DigitStringElement : DigitPosition
| DigitPosition '.'
;
DigitPosition : DigitMapLetter
| DigitMapRange
;
DigitMapRange : 'x'
| '[' DigitLetters ']'
;
DigitLetters : DigitLetter
| DigitLetter DigitLetters
;
DigitLetter : DigitMapLetter
| DIGIT '-' DIGIT
;
DigitMapLetter : DIGIT
| '#' | '*' | 'a' | 'b' | 'c' | 'd'
;
DIGIT : '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9'
;
Example:
0:(0T|8[1-3]xx)
Matches digit string of the form 0 or 8 followed by 1,2 or and 2 more digits.
If anyone would like the code I can post it to the bug tracker.
Clive
More information about the asterisk-dev
mailing list