You should insert some code tags to make it easier to read. Other than that, your logic seems messed up here.

You might try capturing what you want to keep in a s/// substition, like below (untested):

foreach my $i (@n) { # strip any white space $i =~ s/\s//gm; # is the /m multi-line needed? # this checks for beginning with 16 digits, plus a matching string. # this will not match unless both the digits, and the string (plus 3 +0 chars on each end) # are in your string. $i =~ s/^(\d{16}).*?(.{30}Some search tring.{30})/$1$2/gm; # again, +is the /m needed? }
I would highly recommend reading a tutorial, such as
perldoc perlrequick perldoc perlretut

Update: fixed typo in my regex


In reply to Re: regex man they are tough by cowboy
in thread regex man they are tough by tgolf4fun

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.