s/((\n)([^0-9])+(-)*(Aa-Zz)*)|((\n)(\d{3})(-)*(Aa-Zz)*)/$2$3/g

Note that the  Aa-Zz regex subexpression in the quoted regex matches a literal  'Aa-Zz' sequence of these five characters. This subexpression within a (capturing!) group with a  * quantifier means that this sequence may be matched zero or more times.

Perhaps what was meant was a  [a-zA-Z] character class, in which case  [a-zA-Z]* would have been appropriate (or perhaps better [a-zA-Z]+) since the capturing group seems completely unneeded. (But there are many other problems with the original regex, so going back to the beginning and starting from scratch seems the best course; see other suggestions in this thread.)


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


In reply to Re: perl regex to match newline followed by number and text by AnomalousMonk
in thread perl regex to match newline followed by number and text by arunkumarzz

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.