I have for example this string: "iCanSeeBluePeople" and I need it to separate it into array by capital letters and the first word which starts with lowercase so I would recieve array like ["i","Can","See","Blue","People"]
The strings can be like "grandPrix2009" => ["grand","Prix","2009"], "dog" => ["dog"], "aDog" => ["a","Dog"] and so on
I found this code which works fine but I doesn’t apply to numbers and ignores the fist lowercase letter:
<?
$str="MustangBlueHeadlining";
preg_match_all('/[A-Z][^A-Z]*/',$str,$results);
?>
Thanks for help
You can use the regex
/[a-z]+|[A-Z]+[a-z]*|[0-9]+/.Result:
Use
/[a-z]+|[A-Z][a-z]*|[0-9]+/if you wantATestto be separated intoAandTest.Result: