Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
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?
[soonix]: when I read "Joda time format" I thought of "Yoda time format" e.g. ss:mm:HH dd MMM YYYY :-)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2017-03-24 07:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (297 votes). Check out past polls.