Front page | perl.beginners |
Postings from April 2002
Re: regex
Thread Previous
|
Thread Next
From:
drieux
Date:
April 29, 2002 08:48
Subject:
Re: regex
Message ID:
699DB415-5B88-11D6-88C8-0030654D3CAE@wetware.com
On Monday, April 29, 2002, at 07:10 , Bob Showalter wrote:
[..]
>> my $MAXWORD = 15;
>> my $pattern = qr/^\w{1,$MAXWORD}$/;
>
> That matches both "foobar\n" and "foo_bar", which would
> seem to be "illegal" values.
good catch....
I clearly misread what the "\w" would limit on...
> Perhaps the POSIX character class would be useful:
>
> /^[[:alnum:]]{1,15}\z/
>
> Matches the alphabetic character set in the current locale...
my $MINWORD = 1;
my $MAXWORD = 15;
my $pattern = qr/^[[:alnum:]]{$MINWORD,$MAXWORD}$/;
##my $pattern = qr/^[a-zA-Z0-9]{$MINWORD,$MAXWORD}$/;
I had been debating the boring approach of 'if char not in
box' then not in game....
Since that way we can 'grow it' independently as the
security Freaks decide 'must contain one of set.....
also opted to expand it to have the MINWORD value - I
had originally been trying to dink around this with the
use constant FOO => 'bar';
but that did not take me where I wanted to go.....
ciao
drieux
---
Thread Previous
|
Thread Next