Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: N-Queens problem with a regex (again)

by brx (Pilgrim)
on Aug 03, 2007 at 12:15 UTC ( [id://630493]=note: print w/replies, xml ) Need Help??


in reply to Re: N-Queens problem with a regex (again)
in thread N-Queens problem with a regex (again)

It's simply a matter of saving the result then forcing a backtrack.
our @results; / ... The work ... (?{ push @results, ... }) (?!) # Backtrack to find next result. /x;
Another question :)
Is it possible that, with a future version of regex engine, the piece (?!) will be detected as an impossible match so the engine don't even try to match pieces before ?
See the huge difference between the two lines :
"abcde"=~/.*?(.)(?{print $1,"\n"})[0]/; #produce : abcde "abcde"=~/.*?(.)(?{print $1,"\n"})0/; #nothing
Scary ! :-)))

Replies are listed 'Best First'.
Re^3: N-Queens problem with a regex (again)
by ikegami (Patriarch) on Aug 03, 2007 at 12:29 UTC
    It's my not-so-educated-guess that such an optimization is not likely. Such an optimization would be too specific, too little would be gained from the optimization, and it might break existing code.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-04-25 17:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found