Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Perl: the Markov chain saw
 
PerlMonks  

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.


Comment on Re: Regex to compare (if) two strings (Uniquely - I will explain inside)
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (10)
As of 2014-04-17 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (440 votes), past polls