Hi Paul,

Here's what I came up with:

#!/usr/bin/perl
use warnings;
use strict;


my $wordlist = shift @ARGV;

open INPUTFILE, "$wordlist" or die $!;



while (<INPUTFILE>){
# Find all words that are 6-15 characters with at
least 2 digits and 4 letters that can appear anywhere

next unless (/\b\w{6,15}\b\n/ && /.*(\d).*\d/ &&
/(.*([a-z]|[A-Z]).*){4}/);
print;

}



So far i can say that it is working, however i'm not
one 100% sure of it. I'm not really confident about
the positioning. I have to put '.*' before and after
my main expressions... I'm not sure if i'm doing it
right.


With a list file that looks like this:

abcdefghijklmno
222222
abcdef
abcd22
1aniraco
Abcd22
ABCD22
abc2d2
abc1def2ijklmno
222222
abcdef
.ask lasdf


I have managed to extract these:

abcd22
Abcd22
ABCD22
abc2d2
abc1def2ijklmno


That is, regardless of the position, it must have at
least 4 letters and 2 numbers and of course it should
fall between 6 to 15 characters.



In the meantime, let me look at your solution...




--- Paul Lalli <[EMAIL PROTECTED]> wrote:

> On Oct 22, 2:45 am, [EMAIL PROTECTED] (Michael
> Alipio) wrote:
> 
> > The output should be a dictionary file that is
> minimum
> > 6 characters and maximum 15 characters with at
> least 4
> > letters and 2 numbers in it.. no special
> characters
> > whatsoever.. This should be a simple regex but
> it's
> > been a while since i wrote my last regexp program.
> > Need to refresh my perl basics a little bit..
> 
> Don't fall into the trap of trying to express every
> one of your
> requirements as one giant regexp.  There's no reason
> for that.
> 
> > So far I got this:
> >
> > #!/usr/bin/perl
> > use warnings;
> > use strict;
> >
> > my $wordlist = shift @ARGV;
> > #my $newwordlist = shift @ARGV;
> >
> > open INPUTFILE, "$wordlist" or die $!;
> > #open OUTPUTFILE, ">$output" or die $!;
> >
> > while (<INPUTFILE>){
> 
> next unless /^[a-z0-9]{6,15}$/;
> next unless tr/a-z// >= 4;
> next unless tr/0-9// >= 2;
> 
> > print;
> > }
> 
> 
> Paul Lalli
> 
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> http://learn.perl.org/
> 
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Reply via email to