in reply to Re: Re: line endings in remote documents
in thread line endings in remote documents

The other way around :)

Mac  CR   \015     \x0D     \r
DOS  CRLF \015\012 \x0D\x0A \r\n
*Nix LF   \012     \x0A     \n
(Assuming \r is chr(13) and \n is chr(10), which isn't always true)

The regex to substitute them all would be s/\cM|\cM\cJ|\cJ/$foo/, which can be simplified to s/\cM\cJ?|\cJ/$foo/. But if you don't need to substitute, removing can be done a lot faster by just using tr/\cM\cJ//d (the /d will have tr/// delete characters not found in the replacement pattern (the replacenent pattern is empty in this example)).

2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$

Replies are listed 'Best First'.
Re: Re: Re: Re: line endings in remote documents
by belg4mit (Prior) on Dec 20, 2001 at 21:19 UTC
    Except he's using the end of line characters as a means of splitting the input.

    --
    perl -pe "s/\b;([st])/'\1/mg"

      Did he? He did indeed.

      Anyway, same regex (\r\n?|\n), other syntax (split /\r\n?|\n/, $foo).

      I might have caused some confusing, I hope it'll be useful anyway :)

      2;0 juerd@ouranos:~$ perl -e'undef christmas' Segmentation fault 2;139 juerd@ouranos:~$