note 81836 deleted from function.str-split by crell
| From: | crell@php.net | Date: | Wed, 29 Jun 2022 17:56:25 +0000 |
| Subject: | note 81836 deleted from function.str-split by crell | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-218667@lists.php.net to get a copy of this message | ||
Note Submitter: kevin at metalaxe dot com
----
Response to "Richard Ayotte 18-Jan-2008 09:27":
Slight tweak to prevent the need to call another preg_replace, there were also some bugs in this
that I'm surprised didn't get noticed (causing duplicate replaces between the preg_replace
calls) :)
Please feel free to optimize further. I'm not the best with lookahead/behinds yet. I also
removed the :upper/lower: and it seemed to speed things up too.
<?php
$test = 'CustomerIDWithSomeOtherJETWords';
preg_replace('/(?!^)[A-Z]{2,}(?=[A-Z][a-z])|[A-Z][a-z]/', ' $0', $test));
?>
Shaves off a little time anyway. :)