I am looking for something like trim() but for within the bounds of a string. Users sometimes put 2, 3, 4, or more line returns after they type, I need to sanitize this inp
To consider all three line break sequences:
preg_replace('/(?:\r\n|[\r\n]){2,}/', "\n\n", $str)