File: regop.pl

package info (click to toggle)
perl 5.10.1-17squeeze6
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 74,280 kB
  • ctags: 49,087
  • sloc: perl: 319,380; ansic: 193,238; sh: 37,981; pascal: 8,830; lisp: 7,515; cpp: 3,893; makefile: 2,375; xml: 1,972; yacc: 1,555
file content (20 lines) | stat: -rw-r--r-- 640 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use re Debug=>qw(DUMP EXECUTE OFFSETS TRIEC);
my @tests=(
  XY     =>  'X(A|[B]Q||C|D)Y' ,
  foobar =>  '[f][o][o][b][a][r]',
  x  =>  '.[XY].',
  'ABCD' => '(?:ABCP|ABCG|ABCE|ABCB|ABCA|ABCD)',
  'D:\\dev/perl/ver/28321_/perl.exe'=>
  '/(\\.COM|\\.EXE|\\.BAT|\\.CMD|\\.VBS|\\.VBE|\\.JS|\\.JSE|\\.WSF|\\.WSH|\\.pyo|\\.pyc|\\.pyw|\\.py)$/i',
  'q'=>'[q]',
);
while (@tests) {
    my ($str,$pat)=splice @tests,0,2;
    warn "\n";
    $pat="/$pat/" if substr($pat,0,1) ne '/';
    # string eval to get the free regex message in the right place.
    eval qq[
        warn "$str"=~$pat ? "%MATCHED%" : "%FAILED%","\n";
    ];
    die $@ if $@;
}