Justtechjobs.com Find a programming school near you






Online Campus Both


php3-list | 199901

[PHP3] split and keep delimiters From: Christer Lindh (clindh <email protected>)
Date: 01/31/99

One feature I really lack from Perl is that it can split a string into an
array and *keep* the delimiters. You do this by putting the expression
inside a regexp group, ie (....). Example

 <email protected> = split(/([: ,;]+)/, "Lindh, Christer");
$foo[0] == "Lindh"
$foo[1] == ", ";
$foo[2] == "Christer";

If you loose the separator, as in PHP, there's no way to glue that string
back together again.

Is there a way to do this efficiently in PHP?

If not, would it be hard to add this to the split() (and maybe explode with
a optional third argument) function in next release? I think it's very
useful and would speed up text processing a lot.

-- 
| Christer Lindh,   | Homepage   : http://www.homenet.se/clindh/
| Stockholm, Sweden | Utsidan    : http://www.utsidan.se/
| clindh <email protected> | Abbey's Web: http://www.utsidan.se/abbey/

-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>