我将如何拆分单词:
oneTwoThreeFour
放入数组,这样我就可以得到:
one Two Three Four
与preg_match?
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
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.