negating qr// regexp 
Author Message
 negating qr// regexp

        Hallo,

  How to negate a regular expressin, which is stored in a varible:


$_ = "a b";

/[^$save]/o and die "Unsafe";

# perl v 5.6.1 on debian woody returns
# Unmatched ) before HERE mark in regex

I know that fore this keys I have other possibilities how to write it.
But this is a demonstration what I consider as bug.
Why perl searches for ending / inside the compiled subexpression?

        Thanks
                                        Hans



Sun, 28 Dec 2003 22:30:11 GMT  
 negating qr// regexp

Quote:

>         Hallo,

>   How to negate a regular expressin, which is stored in a varible:


> $_ = "a b";

> /[^$save]/o and die "Unsafe";

> # perl v 5.6.1 on debian woody returns
> # Unmatched ) before HERE mark in regex

> I know that fore this keys I have other possibilities how to write it.
> But this is a demonstration what I consider as bug.
> Why perl searches for ending / inside the compiled subexpression?

You are trying to use a character class inside a character class, don't
do that. You don't need the /o modifier because qr// already compiled
your regex.


$_ = "a b";
/$save/ and die "Unsafe";

John
--
use Perl;
program
fulfillment



Wed, 31 Dec 2003 10:46:46 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. negating a string in a regexp

2. regexp to negate 2 chars at once

3. negated compiled regexp

4. Why do qr[\xE0] qr[\x{410}] not interpolated? Gory details not gory enough!

5. Why do qr[\xE0] qr[\x{410}] not interpolated? Gory details not gory enough!

6. qr and backreferences

7. qr, compiling Reg. Exp under Perl 5.003

8. qr, spliting..

9. Discovering whether qr/// needs to recompile an RE

10. qr// vs /o

11. DEMO: new qr// operator

12. qr{} and quoting pattern metachars

 

 
Powered by phpBB® Forum Software