Regular Expressions: Greedy vs. Reluctant Quantifiers

The other day I wanted to extract a part of a filename and was quite dumbfounded when the extracted part came back empty. The regular expression used to extract the part using a capturing group was:


The filenames fed into this expressing where mostly of the pattern However, occasionally a file named would pass along and even though its name matched the expression, the capturing group came up empty. But… but… why?

Find out →

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS