[asterisk-dev] Better pattern matching

Tilghman Lesher tilghman at mail.jeffandtilghman.com
Thu Aug 2 13:18:37 CDT 2007


On Thursday 02 August 2007, John Lange wrote:
> On Thu, 2007-08-02 at 07:13 -0600, Steve Murphy wrote:
> > First of all, regexps implicitly begin with ^ (start of line), and
> > end with $ (end of line). I don't picture just looking for patterns
> > somewhere in the string.
>
> I'm a bit confused by that statement. Are you saying that the
> expression:
>
> exten => /1204/,1, ...
>
> would be implicitly converted to
>
> exten => /^1204$/,1, ...
>
> ? The implicit "^" might make sense, but not the "$". I don't much
> like the idea of the implicit binding of the patterns to the
> beginning and/or end of the match so perhaps you could elaborate why
> you think that's good?

Because the patterns also need to be EXACT matches.  If you want an
inexact match, then you should explicitly state it as ".*".

Also, because we currently use the '/' character as a delimiter for the
optional callerid matching, I think we should use the '^' character to
denote regex matching (since it's implicitly part of the regex anyway).

Presently:
exten => 1204/6152345678,1,...

Proposed:
exten => ^foo[0-9]{4}.*,1,...

-- 
Tilghman



More information about the asterisk-dev mailing list