[Asterisk-Dev] better pattern matcher

Reini Urban r.urban at inode.at
Thu Jun 12 05:11:12 MST 2003


Attached is a matcher which does almost all I need so far.
Again I have long weekend, alternations will have to wait until next monday.

old:
* a regex must start with "_"
* regex patterns are case-insensitive except characters inside []
* "." matches zero or more characters (as in * in glob)
* character ranges as in [0-9a-zA-Z]
* X,Z,N match 0-9,1-9,2-9 resp.

new:
* "?" matches any character
* negation as in [^0] ("any char but 0")
               or [^a-z]
* explicit quantifiers as in X{2,4} ("from 2 to 4 digits"),
                           or X{2,}  ("at least 2 digits"),
                           or X{2}   ("exactly 2 digits"),
* regex-style quantifiers like ?, + and * are supported
   by "{}" grouping.
     ? <=> {0,1}
     + <=> {1,}
     * <=> {0,}
* grouping as in N(1X){1,2}  ("one or two sequences of 1X")
* capturing
   with () grouped matches are stored in subsequent numbered global
   variables, starting with $1, $2 and so on.
* alternation as in (01|0|99) ("01 or 0 or 99")
   This is not yet supported, the subsequent alternatives are not
   checked yet.

-- 
Reini Urban - Entwicklung - http://inode.at
-------------- next part --------------
A non-text attachment was scrubbed...
Name: testmatch.c
Type: text/x-c-code
Size: 10239 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-dev/attachments/20030612/83297ebd/testmatch.bin


More information about the asterisk-dev mailing list