On Jun 12, 2007, at 2:45 AM, Matt Jones wrote:

> I have filenames from various digital cameras:  DSC_1234.jpg,
> CRW1234.jpg, etc.  What I really want is the numeric portion of that
> filename.  How would I extract just that portion?
>
>
> I expect it to involve the regex /\d+/, but I'm unclear how to  
> extract a
> portion of a string matching a regex.
>
> Thank you

Last November (2006), there was a series of postings to the Columbus  
Ruby Brigade list beginning with:
http://groups.google.com/group/columbusrb/browse_frm/thread/ 
9c2e682f9926bad0

This was the pattern that I used when responding to Bill's code  
because many of *my* pictures had names like "100_5142.jpg",  
"100_5143.jpg", etc.

NUMBERED_FILE_PATTERN = %r{^(.*\D)?(\d+)(.+)$}

It became a constant since I used it in three places.

Rob Biedenharn		http://agileconsultingllc.com
Rob / AgileConsultingLLC.com