[Asterisk-Dev] better pattern matcher

Reini Urban r.urban at inode.at
Mon Jun 30 06:47:00 MST 2003


attached is my latest matcher.

fixed a bug in the quantifiers and added support for alternations.
it's not yet solid-proof, but should work for most patterns.

see the tests at the end.


Reini Urban wrote:
> old matcher:
> * 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.
> 
> plus the new one with additional features:
> * "?" 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")


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


More information about the asterisk-dev mailing list