in reply to Replacing \n even when it shouldn't be :/

\s includes all whitespace characters, including a newline. From perlretut:

\s matches a whitespace character, the set [\ \t\r\n\f] and others

You will need to create a character classes which contains just those you wish to delete. [[:blank:]] might be suitable.

Replies are listed 'Best First'.
Re^2: Replacing \n even when it shouldn't be :/
by ultranerds (Hermit) on May 18, 2010 at 08:15 UTC
    Hi,

    Ah wow - never knew that! This seems to do the trick:

    $html =~ s/[ ]{2,5}/ /sig;

    Thanks for your help :) This one was driving me nuts!

    Cheers

    Andy