in reply to Deriving Regular Expressions

I can't help but think japhy's right, but...
(?i-xsm:\s+[a-z][a-z]\+[a-z][a-z]\s+\(\d\d\)\d\d) look at all those repeated elements! yeck.
here's a rework which allows the use of {n}, or optionally (add a true parameter when calling the script) breaks all groups down into \d+ or [a-z]+ groups. Finally, double checks that the produced pattern does match the original string... I was pondering making some handler for \W characters, but that's probably too much for such a tchotchke...
$anynum=$ARGV[0]; chomp($orig=<STDIN>); $i = quotemeta($orig); $i=~ s/[a-z]/l/g; $i =~ s/\d/n/g; while ($i=~/(l+)/g){ if ($anynum) { $i=~s/($1)/'[a-z]+'/e; } else { $i=~s/($1)/"[a-z]{".length ($1)."}"/e; } } while ($i=~/(n+)/g){ if ($anynum) { $i=~s/($1)/"\\d+"/e; } else { $i=~s/($1)/"\\d{".length ($1)."}"/e; } } $i=~s/\s+/s\+/g; $i=qr/$i/; print "pattern is : $i\n"; print $orig=~/$i/; #double check