Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2018-03-17 23:08 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (227 votes). Check out past polls.