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

Re: Regex bug in 5.10 (was: Using Look-ahead and Look-behind)

by jds17 (Pilgrim)
on May 08, 2009 at 19:47 UTC ( #762920=note: print w/replies, xml ) Need Help??


in reply to Regex bug in 5.10 (was: Using Look-ahead and Look-behind)
in thread Using Look-ahead and Look-behind

You are right, my change did not affect greediness. The bad thing is: now I don't understand why my proposed solution worked at all. Maybe someone can explain? I don't think the question is too important, but I like to use regular expressions and it bugs me a little if I cannot understand one (especially such a tiny one).

I have read the documentation you have cited and it helped, so I played around some more and tried out the following, which only exchanges "+" for "*" in your original expression, really works as one would think and therefore would be my preferred solution, at least for Perl 5.10:

$_ = "Hello"; print "$1\n" while /(?=(.+))/g;
Output:
Hello ello llo lo o

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://762920]
help
Chatterbox?
[stevieb]: I have fixed a boatload of issues across several of my distributions, including a couple that have been nagging for a very long time and were exceptionally difficult to solve. Saving $ before we move, so thought I'd have a code session...
[stevieb]: ...session weekend. Went far better than I could have imagined. Even got a bunch of stuff soldered for another one of my electronics projects on the go, and am working on a fix for a MetaCPAN::Client issue I found
[shmem]: the smaller your boat is, the smaller is the load...
shmem is going to look for problems with C++. Urgh.
choroba has worked on the Pull Request Challenge

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2017-06-25 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (571 votes). Check out past polls.