php以大写字母爆炸? [英] php explode at capital letters?

查看:154
本文介绍了php以大写字母爆炸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似的字符串,

$a = 'helloMister';
$b = 'doggyWaltz';
$c = 'bumWipe';
$d = 'pinkNips';

我怎样才能用大写字母爆炸,在谷歌上搜索一段时间,什么都没有回来!

How can I explode at the capital letters, search on google for some time and came back with nothing!

谢谢。

推荐答案

$ c> helloMister 转换为 hello Mister 您可以使用 preg_split 通过使用肯定的前瞻断言来在大写字母之前的一个点处拆分字符串:

If you want to split helloMister into hello and Mister you can use preg_split to split the string at a point just before the uppercase letter by using positive lookahead assertion:

$pieces = preg_split('/(?=[A-Z])/',$str);

,如果您想将它拆分为 hello ister 您可以这样做:

and if you want to split it as hello and ister you can do:

$pieces = preg_split('/[A-Z]/',$str);

这篇关于php以大写字母爆炸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆