[Home]

Summary:ASTERISK-00093: [patch] PBX Regex Matcher enhanced
Reporter:rurban (rurban)Labels:
Date Opened:2003-08-13 02:26:01Date Closed:2011-06-07 14:04:55
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) pbx-matcher-20030630.patch
Description:Feature enhancement for the regex matcher.
Also better readable code (though recursive).

old features:
* 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 (default disabled, enable it with #define AST_PBX_MATCH_CAPTURE)
 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")

Grouping has some limitations: Advanced features inside groups may fool the matcher. See the testmatch.c cases in the list archive.

****** ADDITIONAL INFORMATION ******

code similar to that one posted at http://lists.digium.com/pipermail/asterisk-dev/2003-June/001042.html

In production at inode.at (voip voicemail) for 2 months now.
Comments:By: Mark Spencer (markster) 2003-08-25 21:49:26

This is really quite a remarkable patch and I have few issues with it, except:

1) Setting global variables isn't scalable to beyond more than one concurrent call, so it should presumably either (a) be omitted or (b) be global to the particular channel involved

2) If you haven't sent one in already, we'll need a disclaimer for it (directions on the main page of the bug tracker).  Thanks!

By: John Todd (jtodd) 2003-09-06 02:57:48

Hey, Mr. Urban - these are really neat, but the longer Digium waits for the disclaimer, the harder it will be to patch cleanly without modifications.  Some of us are anxiously awaiting the integration of your patches into the main CVS tree, so I don't have to keep editing the patches every time I update.  :-)

By: rurban (rurban) 2003-09-06 12:00:25

ad 1) setting globals is off per default.
     it requires -D AST_PBX_MATCH_CAPTURE
ad 2) Disclaimer faxed some months ago.

By: John Todd (jtodd) 2003-09-08 03:56:19

Might you be inclined to make some better examples for addition to the README.variables file such that each of your excellent additions might be better understood by users who require some actual demonstrations of each matching type?

By: Mark Spencer (markster) 2003-09-13 15:21:26

Merged in CVS

By: Mark Spencer (markster) 2003-09-13 19:49:43

Had to revert this patch because  it totally breaks matchmore/canmatch functionality which requires we know the state of pattern/data while running.

By: John Todd (jtodd) 2003-09-15 14:03:19

rurban - Did you check this patch with Zap channels that match extensions as they are typed?  That seemed to be one of the problems, though Mark (and unwitting CVS updated users) found some additional problems that did not work as expected.

By: rurban (rurban) 2003-09-16 09:00:39

bad bad. the statemachine is recursive,
so it's not quite easy to implement matchmore().
Sorry, forgot that.

I'll look at it.

By: John Todd (jtodd) 2003-10-19 20:41:50

any progress on this?

By: John Todd (jtodd) 2003-10-29 17:59:44.000-0600

This method still has promise, but the matchmore() problem needs to be solved.

By: jrollyson (jrollyson) 2004-01-12 23:02:19.000-0600

waiting for revised patch.

By: jrollyson (jrollyson) 2004-01-22 23:00:42.000-0600

Placing in feedback pending status, no response from request for submitter to reissue patch.

By: Brian West (bkw918) 2004-01-26 21:39:20.000-0600

going to close till we get a new patch.

By: Digium Subversion (svnbot) 2008-01-15 14:34:18.000-0600

Repository: asterisk
Revision: 1504

U   trunk/channels/chan_sip.c
U   trunk/pbx.c

------------------------------------------------------------------------
r1504 | markster | 2008-01-15 14:34:17 -0600 (Tue, 15 Jan 2008) | 2 lines

Add extended Matching functionality (bug ASTERISK-93)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=1504