note 112958 added to function.preg-split
| From: | anton at zebooka dot com | Date: | Mon, 12 Aug 2013 13:23:25 +0000 |
| Subject: | note 112958 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195939@lists.php.net to get a copy of this message | ||
A not good code in example regexp.
It should be written
preg_split("/[\\s,]+", ...
because there is no special symbol \s (like \n for example) and we need to pass exactly \s, not
symbol that \s may represent.
So we need to escape backslash with backslash
$a = "/[\\s,+]/";
echo $a;
php> /[\s,+]/
----
Server IP: 69.147.83.199
Probable Submitter: 178.49.60.206
----
Manual Page -- http://php.net/manual/en/function.preg-split.php
Edit -- https://master.php.net/note/edit/112958
Del: integrated -- https://master.php.net/note/delete/112958/integrated
Del: useless -- https://master.php.net/note/delete/112958/useless
Del: bad code -- https://master.php.net/note/delete/112958/bad+code
Del: spam -- https://master.php.net/note/delete/112958/spam
Del: non-english -- https://master.php.net/note/delete/112958/non-english
Del: in docs -- https://master.php.net/note/delete/112958/in+docs
Del: other reasons-- https://master.php.net/note/delete/112958
Reject -- https://master.php.net/note/reject/112958
Search -- https://master.php.net/manage/user-notes.php