Programming Perl includes:
Which takes a word, and builds a template from it with the same pattern of vowels and consonants. Although the original is commented. Extending this to handle digits should be easy. The cunning part will be collapsing the multiple character classes down, and using a multiple instead.#!/usr/bin/perl $vowels='aeiouy'; $cons='bcdfghjklmnpqrstvwxzy'; %map={C=>$cons, V=>$vowels; for $class=($vowels, $cons) { for (split //, $class) { map{$_}.=$class; } } for $char (split //, shift) { $pat.="[$map{$char}]"; } $re=qr/^${pat}$/i; print "REGEX is $re\n"; @ARGV='/usr/dict/words' if -t && !@ARGV; while (<>) { print if /$re/; }
This is, of course, left as an exercise for the reader ;-)
--
Tommy
Too stupid to live.
Too stubborn to die.
In reply to Re: Regular Expression Builder
by tommyw
in thread Regular Expression Builder
by Rich36
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |