Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Negative Lookahead Assertion Problem

by Enlil (Parson)
on Jul 18, 2005 at 23:40 UTC ( #475924=note: print w/ replies, xml ) Need Help??


in reply to Negative Lookahead Assertion Problem

Since your question as to why it doesn't work has been answered. (Basically it will backtrack till it does, and by moving a character back satisfies the regex.)

This should work:/\w+::(?>\w+)(?!\s*\()/

#!/usr/bin/perl use strict; use warnings; my @strings = ( '1. Foo::Bar', '2. Foo::Bar(', '3. Foo::Bar (', '4. Foo::Bar ' ); for ( @strings ) { print $_,$/ if /\w+::(?>\w+)(?!\s*\()/; } __END__ 1. Foo::Bar 4. Foo::Bar
Have a look at perlre where it reads about (?>pattern)

-Enlil


Comment on Re: Negative Lookahead Assertion Problem
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://475924]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-12-27 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls