Eh, why a regexp? This is what I use:
#!/usr/bin/perl use 5.010; use strict; use warnings; use Getopt::Long; use List::Util 'sum'; my %tiles = qw [ A 1 B 3 C 3 D 2 E 1 F 4 G 2 H 4 I 1 J 8 K 5 L 1 M 3 N 1 O 1 P 3 Q 10 R 1 S 1 T 1 U 1 V 4 W 4 X 8 Y 4 Z 10 ]; die "No rack?\n" unless @ARGV; my ($rack, $blanks) = (@ARGV, 0); my $full = length($rack) + $blanks == 7; my %target; $target{$_}++ for split //, $rack; my @words = `cat /usr/share/dict/words`; chomp @words; my @good; my %discount; WORD: foreach my $word (@words) { next unless $word =~ /^[a-z]+$/; my %copy = %target; my $b = 0; my $d = 0; foreach my $c (split //, $word) { if (--$copy{$c} < 0) { $b++; $d += $tiles{uc $c}; $discount{$word} = $d; } next WORD if $b > $blanks; } push @good, $word; } my $tl = length($rack) + $blanks; @good = sort {$a->[1] <=> $b->[1]} map {[$_, sum (map {$tiles{uc $_}} split //) - ($discount{$_} || 0) + ($full && length($_) == $tl ? 50 : 0)]} @good; printf "%2d: %s\n", $_->[1], $_->[0] for @good; __END__
Usage: ./program rack [nr-of-blanks], were rack are the non-blank tiles, and there's an optional number of blanks.

In reply to Re: Regex question once-only use of chars in a charset by JavaFan
in thread Regex question once-only use of chars in a charset by gje21c

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.