note 83512 deleted from function.preg-split by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 08:01:54 +0000 |
| Subject: | note 83512 deleted from function.preg-split by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196743@lists.php.net to get a copy of this message | ||
Note Submitter: m dot timmermans at home dot NOSPAM dot nl
----
For people who want to use the double quote to group words/fields, kind of like CSV does, you can
use the following expression:
<?php
$keywords = preg_split( "/[\s,]*\\\"([^\\\"]+)\\\"[\s,]*|[\s,]+/",
"textline with, commas and \"quoted text\" inserted", 0,
PREG_SPLIT_DELIM_CAPTURE );
?>
Which will result in:
Array
(
[0] => textline
[1] => with
[2] => commas
[3] => and
[4] => quoted text
[5] => inserted
)