Re: regex to match a range of numbers

2006-06-08 Thread Flemming Greve Skovengaard
Joshua Colson wrote: On Thu, 2006-06-08 at 00:55 +0200, Flemming Greve Skovengaard wrote: If you are just going to print the day number and you have other dates in a similar format why not just use: print +(split /\s+/, $date)[2]; Well, in this particular instance, I am. However, there have

regex to match a range of numbers

2006-06-07 Thread Joshua Colson
I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand that there are numerous modules that can do the work for me, this is as much for my own learning as anything. Thanks.

Re: regex to match a range of numbers

2006-06-07 Thread Flemming Greve Skovengaard
Joshua Colson wrote: I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand that there are numerous modules that can do the work for me, this is as much for my own learning as anything.

Re: regex to match a range of numbers

2006-06-07 Thread John W. Krahn
Joshua Colson wrote: I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand that there are numerous modules that can do the work for me, this is as much for my own learning as

Re: regex to match a range of numbers

2006-06-07 Thread Joshua Colson
On Wed, 2006-06-07 at 16:20 -0600, Jeremy Vinding wrote: Joshua Colson wrote: print $3 if $date =~ m{(Wed)\s(Jun)\s{1,2}([1..31])}; I believe you'd have to use alternation. for example, something like: /(0?[1-9]|[12][0-9]|3[01])/ or /([012]?[1-9]|[1-3]0|31)/ That does work.

Re: regex to match a range of numbers

2006-06-07 Thread Joshua Colson
On Wed, 2006-06-07 at 15:55 -0700, John W. Krahn wrote: print $1 if $date =~ m{ Wed \s Jun \s\s? ( [1-9] | [1-2]\d | 3[0-1] ) \s }x; Isn't

Re: regex to match a range of numbers

2006-06-07 Thread Joshua Colson
On Thu, 2006-06-08 at 00:55 +0200, Flemming Greve Skovengaard wrote: If you are just going to print the day number and you have other dates in a similar format why not just use: print +(split /\s+/, $date)[2]; Well, in this particular instance, I am. However, there have been at least a few

Re: regex to match a range of numbers

2006-06-07 Thread Dr.Ruud
Joshua Colson schreef: I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand that there are numerous modules that can do the work for me, this is as much for my own learning as

Re: regex to match a range of numbers

2006-06-07 Thread John W. Krahn
Joshua Colson wrote: On Wed, 2006-06-07 at 16:20 -0600, Jeremy Vinding wrote: Joshua Colson wrote: print $3 if $date =~ m{(Wed)\s(Jun)\s{1,2}([1..31])}; I believe you'd have to use alternation. for example, something like: /(0?[1-9]|[12][0-9]|3[01])/ or /([012]?[1-9]|[1-3]0|31)/ That does

Re: regex to match a range of numbers?

2006-06-07 Thread Anthony Ettinger
You can simply split on whitespace. http://perl-e.chovy.com/sample/date-parse On 6/7/06, Joshua Colson [EMAIL PROTECTED] wrote: I'm trying to parse a date from a file and I would like to know how to match a range of numbers with a regex? For example, the days of the month 1..31. I understand