in reply to perl regex to match newline followed by number and text

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:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^2: perl regex to match newline followed by number and text
by arunkumarzz (Novice) on Jun 02, 2019 at 06:17 UTC
    Sorry, my regex might work in Oracle but its different in perl! Thanks for your response.