<?xml version="1.0" encoding="windows-1252"?>
<node id="1005447" title="Re: Regex to compare (if) two strings (Uniquely - I will explain inside)" created="2012-11-24 20:32:37" updated="2012-11-24 20:32:37">
<type id="11">
note</type>
<author id="634253">
AnomalousMonk</author>
<data>
<field name="doctext">
&lt;p&gt;
Further to [id://1005414|previous post]: A solution using a regex per OP request. No hashes. Note that the function now takes &lt;i&gt;two strings,&lt;/I&gt; not a string and a hash. Tested, works.
&lt;/P&gt;

&lt;c&gt;
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;

    }
&lt;/C&gt;

&lt;p&gt;
&lt;b&gt;Update:&lt;/B&gt; Instead of &lt;br&gt;
&lt;c&gt;    $tray =~ s/$_//xms or return for map quotemeta, split '', $word;&lt;/c&gt; &lt;br&gt; 
using &lt;br&gt;
&lt;c&gt;    $tray =~ s/\Q$_\E//xms or return for split '', $word;&lt;/c&gt; &lt;br&gt; 
might be slightly faster because it avoids having &lt;c&gt; map quotemeta &lt;/C&gt; build another intermediate array. (Tested.)
&lt;/P&gt;
</field>
<field name="root_node">
1005402</field>
<field name="parent_node">
1005402</field>
</data>
</node>
