使用php preg_match(正则表达式)将camelCase单词拆分为单词
我将如何拆分单词:
oneTwoThreeFour
放入数组,这样我就可以得到:
one Two Three Four
与preg_match
?
我很累,但这只是整个词
$words = preg_match("/[a-zA-Z]*(?:[a-z][a-zA-Z]*[A-Z]|[A-Z][a-zA-Z]*[a-z])[a-zA-Z]*\b/", $string, $matches)`;
回答:
您还可以preg_match_all
用作:
preg_match_all('/((?:^|[A-Z])[a-z]+)/',$str,$matches);
说明:
( - Start of capturing parenthesis. (?: - Start of non-capturing parenthesis.
^ - Start anchor.
| - Alternation.
[A-Z] - Any one capital letter.
) - End of non-capturing parenthesis.
[a-z]+ - one ore more lowercase letter.
) - End of capturing parenthesis.
以上是 使用php preg_match(正则表达式)将camelCase单词拆分为单词 的全部内容, 来源链接: utcz.com/qa/401013.html