note 73309 added to function.preg-split

From: Date: Sat, 17 Feb 2007 03:32:33 +0000
Subject: note 73309 added to function.preg-split
Groups: php.notes 
Request: Send a blank email to php-notes+get-123503@lists.php.net to get a copy of this message
Thanks to "s" I figured out how to split a sentence based on commas and quotes, without losing the commas and quotes. It requires the addition of parenthesis to the expression, leaving me with what I call the "breast" split: preg_split("((,)|( ))", $mystring, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); Okay obviously that SHOULD be "((,)|(\s))", but both work. For the phrase: "you, and" You end up with: you , and ---- Server IP: 216.194.113.175 Probable Submitter: 207.13.235.29 ---- Manual Page -- http://www.php.net/manual/en/function.preg-split.php Edit -- https://master.php.net/note/edit/73309 Del: integrated -- https://master.php.net/note/delete/73309/integrated Del: useless -- https://master.php.net/note/delete/73309/useless Del: bad code -- https://master.php.net/note/delete/73309/bad+code Del: spam -- https://master.php.net/note/delete/73309/spam Del: non-english -- https://master.php.net/note/delete/73309/non-english Del: in docs -- https://master.php.net/note/delete/73309/in+docs Del: other reasons-- https://master.php.net/note/delete/73309 Reject -- https://master.php.net/note/reject/73309 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#123503) next »