'Regex for use with PHP's preg_match() to find a newline

I'm fairly new/rusty with regular expressions. I'm collecting a block of text from a textarea element and I want to check to see if the person who filled it used any paragraphs, amongst other things.

I'm using the following and I know it's wrong.

preg_match('/\r\n|\n|\r/', $_GET['text']);


Solution 1:[1]

Assuming:

This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph. This is a paragraph.

And this is another. And this is another. And this is another. And this is another. And this is another. And this is another. And this is another. And this is another. And this is another. And this is another.

You could just do:

if (str_replace("\r\n\r\n", '', $str) != $str)
  // the input contains at least two paragraphs

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1