note 73309 deleted from function.preg-split by tularis

From: Date: Thu, 03 May 2007 22:24:33 +0000
Subject: note 73309 deleted from function.preg-split by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126172@lists.php.net to get a copy of this message
Note Submitter: Tony ---- 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

« previous php.notes (#126172) next »