in reply to Negative Lookahead Assertion Problem
The following code:
#!/usr/bin/perl -w use strict; my @strings = ( "Foo::Bar()", "Foo::Bar ()", "Foo::Bar ()", " Foo::Bar()", " Foo::Bar ()" ); my %test = ( 1 => qr/Foo::Bar(?!\s*\()/, 2 => qr/Foo::Bar(?!\s+\()/ );
foreach my $teststring ( @strings ) { print( "---$teststring---\n" ); foreach my $testnum ( sort { $a <=> $b } keys %test ) { if ( $teststring =~ m/$test{$testnum}/ ) { print( "test $testnum matches\n" ); } else { print( "test $testnum does not match\n" ); } } }
---Foo::Bar()--- test 1 does not match test 2 matches ---Foo::Bar ()--- test 1 does not match test 2 does not match ---Foo::Bar ()--- test 1 does not match test 2 does not match --- Foo::Bar()--- test 1 does not match test 2 matches --- Foo::Bar ()--- test 1 does not match test 2 does not match
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Negative Lookahead Assertion Problem
by ysth (Canon) on Jul 19, 2005 at 06:25 UTC | |
by monarch (Priest) on Jul 19, 2005 at 11:39 UTC | |
by ysth (Canon) on Jul 19, 2005 at 20:12 UTC | |
|
Re^2: Negative Lookahead Assertion Problem
by Limbic~Region (Chancellor) on Jul 19, 2005 at 14:07 UTC |