As this question, I can split strings that includes upper cases like this:
function splitAtUpperCase($string){
return preg_replace('/([a-z0-9])?([A-Z])/','$1 $2',$string);
}
$string = 'setIfUnmodifiedSince';
echo splitAtUpperCase($string);
Output is "set If Unmodified Since"
But I need some modification:
ÇÖĞŞÜİ
. I don't want to transliterate the characters. Then I lose meaning of word. I need to use some UTF characters. That code makes "HereÇonThen" to "HereÇon Then"cases and expected results
For these cases I use subsequent str_replace
operations. I look for a short solution that doesn't make too much for loops to check the words. It would be better to have it as preg_replace
or etc. if possible.
Edit: Anyone can try his solution by changing convert
function inside this PHP fiddle: http://ideone.com/9gajZ8
/([[:lower:][:digit:]])?([[:upper:]]+)/u
should do it.
Here /u
is used for Unicode characters. and ([[:upper:]]+)
is used for Sequence of upper cased letters.
Note. Case of a letter depends on the character set you are using.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With