I can't help but think japhy's right, but...
(?i-xsm:\s+[a-z][a-z]\+[a-z][a-z]\s+\(\d\d\)\d\d) look at all those repeated elements! yeck.
here's a rework which allows the use of {n}, or optionally (add a true parameter when calling the script) breaks all groups down into \d+ or [a-z]+ groups. Finally, double checks that the produced pattern does match the original string... I was pondering making some handler for \W characters, but that's probably too much for such a tchotchke...
$anynum=$ARGV[0]; chomp($orig=<STDIN>); $i = quotemeta($orig); $i=~ s/[a-z]/l/g; $i =~ s/\d/n/g; while ($i=~/(l+)/g){ if ($anynum) { $i=~s/($1)/'[a-z]+'/e; } else { $i=~s/($1)/"[a-z]{".length ($1)."}"/e; } } while ($i=~/(n+)/g){ if ($anynum) { $i=~s/($1)/"\\d+"/e; } else { $i=~s/($1)/"\\d{".length ($1)."}"/e; } } $i=~s/\s+/s\+/g; $i=qr/$i/; print "pattern is : $i\n"; print $orig=~/$i/; #double check

In reply to Re: Deriving Regular Expressions (boo) by boo_radley
in thread Deriving Regular Expressions by mojotoad

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.