Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

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

by BrowserUk (Pope)
on Nov 24, 2012 at 17:43 UTC ( #1005406=note: print w/ replies, xml ) Need Help??


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

Sort the letters in both strings and compare the results:

$randword = join'', ('A'..'Z')[ map rand 26, 1..8 ];; print $randword;; LDAZAJSA chomp( $input = <STDIN> );; AAADJLSZ print join('', sort split '', $randword ) eq join( '', sort split '', +$input ) ? 'Ok' : 'Bad';; Ok

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

RIP Neil Armstrong


Comment on Re: Regex to compare (if) two strings (Uniquely - I will explain inside)
Download Code
Re^2: Regex to compare (if) two strings (Uniquely - I will explain inside)
by frozenwithjoy (Curate) on Nov 24, 2012 at 18:29 UTC
    I really like the way you are generating the random word; however, my understanding is that sub-sets of letters may be used to make words and your comparison at the end will only work if all letters are used when the user creates a word.

      Looking at the OP a second time:

      Input a word from user (that they make FROM the 8 random chars such as in Scrabble).

      You are probably right. Mea culpa.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      RIP Neil Armstrong

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2014-10-20 22:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (92 votes), past polls