in reply to Matching dialplan rules...
Definitely when writing a complex one like this, use the /x modifier to make things clearer to yourself. Taking your expression as is:
$pattern =~ / ^ _* # 0 or more underscores to start ( (\d*|#*|\**)+ # Any combo of digits, #s, or *s (\[\d+\-\d\])? # Maybe a [x-y] ) (X*\.?\!?) # Zero or more Xs, and maybe a . or ! $ /gx;
The other thing I'd recommend doing is writing a test script to make sure your regex works.
use strict; use warnings; use Test::More qw(no_plan); my $regex = qr{ ... stuff ... }x; # Tests like( '100', $regex, 'Valid numeric' ); like( '_100', $regex, 'Valid numeric with leading underscore' ); # etc. unlike( '', $regex, 'Invalid empty string' ); # etc.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Matching dialplan rules...
by Anonymous Monk on Dec 04, 2008 at 14:49 UTC |