in reply to Regex matching on grid alignment

x x x x 1 2 3 4 (.) \1 \1 (.) \1 \1
x x x x x x 1 2 3 4 5 6 (.) \1 \1 #r1 (.) \1 \1 #r2 (.) \1 \1 #r3 (.) \1 \1 #r4

6 length - 3 consecutive = 3 leading

...(.)\1\1 ..(.)\1\1. .(.)\1\1.. (.)\1\1... (.)\1\1(.)\1\1

So m{(.)\1\1(.)\1\1 |(.)\1\1... |.(.)\1\1.. |..(.)\1\1. |...(.)\1\1 }x

Replies are listed 'Best First'.
Re^2: Regex matching on grid alignment
by Anonymous Monk on Sep 08, 2013 at 21:47 UTC
    Actually it needs branch-reset , which I remember from Finding repeat sequences., so like
    m{ (?| (.)\1\1(.)\1\1 |(.)\1\1... |.(.)\1\1.. |..(.)\1\1. |...(.)\1\1 ){4} ## 6 x 4 }x;

    Generating (and testing) this regex left up to the OP (hopefully you can see the relation between the various numbers)

      :) perl before 5.10 (before branch reset available ) would need () counting like (.)\1\1(.)\2\2 |(.)\3\3... |.(.)\4\4.. |..(.)\5\5. |...(.)\6\6