I need to right a regular expression that will find a X length string at the begining and a string of the same lenght at the end of a pattern, (also similar circumstances in the midle) I know the length of the patterns at the end but not the middle, and I know how they relate to each other, I also know that there can be one miss (IE if there are 4 characters only 3 have to follow the pattern) I was thinking of something like /(.{4})(\1 =~ tr/something/somethingelse/)/) but that doesnt work, or running a subroutine on \1 or $1 like /(.{4})(trans (\1))/ or $1, please help also there can be one miss on each group and it still has to find it, is it even possible to do this?

In reply to subroutine within a regular expression and allowing for a miss 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.