Gunwant Singh schreef:
> I have a query regarding regexes.
No, you don't.
> I am to match only one specific word in a wordlist which has only
> those alphabets which it contains and none other than that.
To do that, you can use regexes, but you don't need to.
> My Wordlist contains:
>
> alpha
> alpha1
> beta
> betaze
> gamma
> gamman
> gammano
>
> I want to match any scrambled word with a word in the wordlist which
> has exactly the same alphabets may be unscrambled/scrambled no other
> alphabets. Say, If I enter 'ammag' (scrambled word for gamma), it
> should only match 'gamma' and NOT 'gamman' | 'gammano'
Then the first thing you will check is the length. You don't need a
regex to do that, though you can use a regex, but normally you would use
the builtin function length(). (see `perldoc -f length`)
After this you need to compare the character frequencies.
An easy way to do that is to transform your word to a scrambled version
where the characters are sorted internally (gamma -> aagmm).
You can do that once with your Wordlist (and store that as
Wordlist.unified).
perl -wle '
$word = "Gamma";
$sorted = join "", sort split "", lc($word);
print $sorted;
'
aagmm
--
Affijn, Ruud
"Gewoon is een tijger."
Thread Previous
|
Thread Next