Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Regex to compare (if) two strings (Uniquely - I will explain inside)

by moritz (Cardinal)
on Nov 24, 2012 at 17:35 UTC ( #1005404=note: print w/replies, xml ) Need Help??

in reply to Regex to compare (if) two strings (Uniquely - I will explain inside)

if ($word =~ /[$random_string]$/i)

That only checks the last character from $word.

I don't think regexes are a good tool for the job. Instead keep a hash of how often each character may appear in the string. Iterate through all characters of the string, and for each character check if it's still allowed. If no, give out an error message. If yes, decrease the allowed count for that character.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005404]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2016-10-27 01:49 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (352 votes). Check out past polls.