I want to replace multiple newline characters with one newline character, and multiple spaces with a single space.
I tried preg_replace(\"/\\n\\n+/\", \"\\n\",
preg_replace(\"/\\n\\n+/\", \"\\n\",
If you just want to replace multiple tabs with a single tab, use the following code.
preg_replace("/\s{2,}/", "\t", $string);