/\A (?= [[:alpha:]]{12} \Z) (?! .* (.) \g-1) (?= .* (.) .+ \g-1)/x and print

But if you're scanning a dictionary, don't you know to begin with that all the words are words? It might be faster to scan with
    /\A (?= .{12} \Z) (?! .* (.) \g-1) (?= .* (.) .+ \g-1)/x and print
(OTOH, I know that some dictionaries include apostrophized and hyphenated words, so maybe you need to be specific. (Update: Upon further investigation, I find that the dictionary file I'm using does, indeed, include words like "wristwatch's", so [[:alpha:]]{12} vs. .{12} makes a difference for me.))

Update 1: Note that the regexes above need Perl version 5.10+ to support the \g{n} backreference operator.

Update 2: I second GrandFather's point about splitting up the components of a complex filter regex into individual regexes: they become simpler and easier to understand and manage, In that vein:

c:\@Work\Perl>perl -wMstrict -n -le "BEGIN { $::n = 0 } /\A .{12} \z/x && !/(.) \g-1/x && /(.) .+ \g-1/x and ++$::n and print; END { print \"$::n found\" } " ..\moby\mwords\354984si.ngl
(All the stuff with $::n is for development/debug only; it can be discarded for end use.)


Give a man a fish:  <%-{-{-{-<


In reply to Re: Words, no consecutive doubled letters but repeated letters (updated x2) by AnomalousMonk
in thread Words, no consecutive doubled letters but repeated letters by wlegrand

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.