note 88989 deleted from function.preg-split by danbrown
| From: | danbrown@php.net | Date: | Tue, 17 Feb 2009 18:00:31 +0000 |
| Subject: | note 88989 deleted from function.preg-split by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-150753@lists.php.net to get a copy of this message | ||
Note Submitter: jasper [] horn [at] gmail [dot] com
----
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.