View Single Post
Old 12-06-2007, 07:47 PM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

I've sort of come up with a solution on my own, but it feels a little hackish with all those "OR"s in:

php Code:
$szChem = 'H2OCe5CO5L';
preg_match_all('~[^\P{Lu}]{1}[^\P{Ll}]+\d+|[^\P{Lu}]{1}\d+|[^\P{Lu}]{1}[^\P{Ll}]+|[^\P{Lu}]{1}~', $szChem, $aMatches);

print_r($aMatches);

Be much easier if I could split by the uppercase letters, but still retain the uppercase letters and include them alongside the matches, as opposed to in a separate array index.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote