<?php $text = "*After Cesar had reported this, he\r\n jumped into his UFO and flew to space*\r\nStory goes on ... with some text.\r\n*Another section with\r\na linefeed within asterisks*"; echo preg_replace_callback('~\*[^*]*\*~', function($x) { return str_replace(["\r","\n"], '', $x[0]); }, $text);
You have javascript disabled. You will not be able to edit any code.