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. However, I was hoping for something a little more
concise. Such as:

...SNIP...

my $pattern = join("|", reverse 1..31);

my $string = '15 18 50 1 0 45 12 22';

print $1, "\n" while( $string =~ m/\D($pattern)\D/g );

...END SNIP...

However, the previous code does not match the numbers at the beginning and end 
of the line. I know that I could put the non-digits into negative and positive 
looking assertions, but this just keeps getting less and less clean.

Thanks again.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to