Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005404]
help
Chatterbox?
[ambrus]: Yes, I was explaining him why I believe it's impossible.
[Corion]: But he doesn't want to listen or does he not understand why/where it's impossible to get from the input to the output?
[Corion]: (or both?)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-12-12 13:20 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (332 votes). Check out past polls.

    Notices?