Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Error in my Regular expression pattern

by JavaFan (Canon)
on Mar 18, 2012 at 12:52 UTC ( #960287=note: print w/ replies, xml ) Need Help??


in reply to Error in my Regular expression pattern

Consider this:

  • You have a deck of cards (52).
  • You remove the top card.
  • You deal the remaining cards among 4 players.
  • You end up one short.
  • Now, you collect all cards again.
  • This time, you don't remove the top card.
  • You deal the remaining card among the 4 players.
Do you now wonder how it comes that if you don't remove the top card, you can deal 52 cards evenly, but you cannot if you do?

That's the same what's happening here. There are 2 matches of twinkle in your string. If you first match one, then the rest, the "rest" only matches once. If you only match "the rest", you get both matches.


Comment on Re: Error in my Regular expression pattern

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-12-18 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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





    Results (41 votes), past polls