note 88989 added to function.preg-split
| From: | jasper | Date: | Tue, 17 Feb 2009 16:37:38 +0000 |
| Subject: | note 88989 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150752@lists.php.net to get a copy of this message | ||
harriswm:
As merlinyoda mentioned, you are not using any benefit of regexes, so you are better off using
explode instead. However, you also mentioned wanting to do this with a single call to preg_split,
which is not all that hard if you have some knowledge of regexes, it's simply:
<?php preg_split('~(' . $part1 . ')|(' . $part2 . ')|(' . $part3 .
')~'); ?>
I would still advise against using regular expressions here, though. Personally I would need a very
good reason to use a regular expression that is not a constant in my code. Regular expressions just
do have to many variables to let the regular expression depend on the situation completely.
----
Server IP: 213.249.64.162
Probable Submitter: 94.210.186.28
----
Manual Page -- http://www.php.net/manual/en/function.preg-split.php
Edit -- https://master.php.net/note/edit/88989
Del: integrated -- https://master.php.net/note/delete/88989/integrated
Del: useless -- https://master.php.net/note/delete/88989/useless
Del: bad code -- https://master.php.net/note/delete/88989/bad+code
Del: spam -- https://master.php.net/note/delete/88989/spam
Del: non-english -- https://master.php.net/note/delete/88989/non-english
Del: in docs -- https://master.php.net/note/delete/88989/in+docs
Del: other reasons-- https://master.php.net/note/delete/88989
Reject -- https://master.php.net/note/reject/88989
Search -- https://master.php.net/manage/user-notes.php