Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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

by AnomalousMonk (Chancellor)
on Nov 25, 2012 at 01:32 UTC ( #1005447=note: print w/replies, xml ) Need Help??

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

Further to previous post: A solution using a regex per OP request. No hashes. Note that the function now takes two strings, not a string and a hash. Tested, works.

sub scrabblicious { my ($word, # word to test for scrabble match to tray of letters $tray, # string with 'tray' of letters to select from ) = @_; return if not length $word; # special case: empty string $tray =~ s/$_//xms or return for map quotemeta, split '', $word; return 1; }

Update: Instead of
    $tray =~ s/$_//xms or return for map quotemeta, split '', $word;
    $tray =~ s/\Q$_\E//xms or return for split '', $word;
might be slightly faster because it avoids having  map quotemeta build another intermediate array. (Tested.)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1005447]
LanX Much enemy much ore
[Corion]: marto: Naah, my module doesn't care, but the users of my module might expect some things to work in Chrome that only work in later builds (or, as seems to be the case, don't work there either ;) )
[Corion]: But I really wonder - I can tell Chrome to go offline, but requesting pages over the network still succeeds. But if I manually click the "offline" checkbox, that's different :-/
[LanX]: Corion can you tell WMC to check the sub version number ?

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2017-12-12 20:28 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (336 votes). Check out past polls.