in reply to Re: regex doubt on excluding
in thread regex doubt on excluding

Yes, that's it, Preserve multiple empty lines. (but without white-spaces)

Replies are listed 'Best First'.
Re^3: regex doubt on excluding
by hdb (Monsignor) on Apr 21, 2014 at 08:46 UTC

    How about this?

    $string =~ s/^\s*?\n$/\n/mg;

    UPDATE: the regex is not working properly but this should, the \n and the $ are somewhat duplicate:

    $string =~ s/^\s*?\n/\n/mg;

      Thank you hdb... it worked...

      its working with $string =~ s/^\s*?\n/\n/mg; too... :-)