Thank you LanX. I'll try to explain a little more. The "match 3 of the same character in a row" is the ONLY pattern I have that must not break row boundaries. The other patterns are more complex, but here are a few examples (from memroy, please forgive mistakes):

/(.).{$width}\1.{$width}\1/; # 3 in a line vertically /^(.)(?!\1)(.)(?:\1\2)+\1?$/; # XoXoX # oXoXo # XoXoX # oXoXo

Sorry, these are about the only two I had any hope of getting right from memory. :-) There are others that look for dynamic "walking" patterns of symbols, stairstep patterns, various symmetries, and Jimmy Hoffa (if our grant approval ever goes through). Several of them share parts with others, so they combine quite nicely into a single expression.

I thought of using a row separator as well, but patterns not much more complex than the first get a lot less readable and slower when you start to have to have a lot of +1's and -1's to account for the different width, and exceptions so that it doesn't match three \0's in a row at the end of the lines. Patterns like the second, frankly I think it would be easier (for both man and machine) to copy the string and tr/\0//d. That wouldn't be horrible, but definitely preferable to just have another regexp to optimize with others than to have two data representations.


In reply to Re^2: Regex matching on grid alignment by Anonymous Monk
in thread Regex matching on grid alignment by Anonymous Monk

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.