note 36961 added to function.preg-split
| From: | galium at sandnarrows dot com | Date: | Tue, 28 Oct 2003 23:15:52 +0000 |
| Subject: | note 36961 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-59447@lists.php.net to get a copy of this message | ||
Struggled with this today and just thought I would toss out a note in case anyone else has a
problem. When using PREG_SPLIT_DELIM_CAPTURE the note about parenthesized expression is rather
important.
If you do: preg_split('( and | or | not )',"blah and blarg or
ick",-1,PREG_SPLIT_DELIM_CAPTURE);
It returns: Array ( [0] => blah [1] => blarg [2] => ick )
Notice the delimiters are missing.
If you put extra () in: preg_split('(( and )|( or )|( not ))',"blah and blarg or
ick",-1,PREG_SPLIT_DELIM_CAPTURE);
It returns: Array ( [0] => blah [1] => and [2] => blarg [3] => [4] => or [5] =>
ick )
----
Manual Page -- http://www.php.net/manual/en/function.preg-split.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+36961
Delete -- http://master.php.net/manage/user-notes.php?action=delete+36961&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+36961&report=yes
Search -- http://master.php.net/manage/user-notes.php