in reply to Regex with newline

Update: Thanks for the help. It was the return character. This works:
$text =~ s|\r\n\r\n|<br /><br />|sg;

Replies are listed 'Best First'.
Re: Re: Regex with newline
by dvergin (Monsignor) on Apr 05, 2001 at 03:21 UTC
    Note that thabenksta's example does not include the '/s'. You do not need it and you obscure its meaning and usefulness when you use it reflexively just because you are working with multiple lines.

    '/s' simply allows '.' to match line break characters. It has no other effect on the ability of your regex to work with multiple lines.

Re^2: Regex with newline
by typomaniac (Novice) on Feb 07, 2012 at 02:50 UTC
    I know this was an old post but it answered a question for me however it also brought up another one....is there any way to limit the number of
    tags to only two..that is, no matter how many times a user presses the enter key paragraphs are separated by two spaces(and no more than two). Thanks
      Yes. For example:
      $text =~ s%(?:\r\n){2,}%<br /><br />%g;