regex - How to parse \n symbols in text from text area with PHP -
regex - How to parse \n symbols in text from text area with PHP -
i have text area, need parse text when form submitted.
for illustration need first string text area, , left whole text is. don't want utilize nl2br
function , utilize pattern <br />
. can parse \n
chars , if how? can't in php code, can in regex tester link illustration below.
http://regex101.com/r/mk7hf2
this code doesn't work:
preg_match('/(.+)\n\n/', $_post['text'],$title); $title = $title[0]; echo $title;
it returns nothing. help me alter this, thanks.
edit
you don't need regular expressions this, utilize strtok:
$title = strtok( $_post['text'], "\n" );
edit
ok, seek \r
match type of line endings '/(.+)\r/'
php regex parsing textarea newline
Comments
Post a Comment