There are no spaces between the words, the string is split into an array and each word is an item within the array. I loop through the array and reverse the words.
Wbos
So would you be reversing each word and capitalizing the first letter of each reversed word before concatenation? Or are you just taking the original character position within the overall string?
If you're doing the former, I might be tempted to do something like the following:
Pseudo Code
- Split the string on space
-
Loop through the resulting array of strings
-
Loop through the string
-
Check the state of capitalized letters within the string storing positions of the capital letters in an array
-
End Loop
-
Reverse the string.
-
Loop through each value in the case state array
-
Capitalize each of the characters at the position stored in the array
-
End Loop
-
End Loop
-
Concatenate strings back together
If performance is an issue though, this process could be a little restrictive...it's perhaps not the most efficient process...but I don't think there's a method that will give you a list of the positions of capitalized characters in a string...so you'd have to write one of your own.