Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
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 cooling their heels in the Monastery: (7)
As of 2015-08-02 22:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (16 votes), past polls