Help for this page

Select Code to Download


  1. or download this
    my $re_single = qr/
        (?:\A|[\r\n]) # either the start of text or newline
    ...
            (?:\z|(?:\r\n|\n\r|\r|\n)\z) # last nl or eof
        )
    /xs;
    
  2. or download this
    my $re_single = qr/
       ^ ( .* \n? \z )
    ...
    /mx;
    
    $String =~ s/\r\n|\n\r|\r|\n/\n/g;
    
  3. or download this
    my $re_single = qr/
        (?:\A|[\r\n]) # either the start of text or newline
    ...
            return( "" );
        }
    }
    
  4. or download this
    sub Last_N_Lines {
        my ( $str, $n ) = @_;
    ...
    }
    
    $String =~ s/\r\n|\n\r|\r|\n/\n/g;