Any ideas how to effeciently convert the String "TDMaturityReinvestOnNotSelected" to "TD Maturity Reinvest On Not Selected" using a java function?
Cheers Shaun
Any ideas how to effeciently convert the String "TDMaturityReinvestOnNotSelected" to "TD Maturity Reinvest On Not Selected" using a java function?
Cheers Shaun
This brilliant answer to RegEx to split camelCase or TitleCase (advanced) should work nicely.
Below is an excerpt from that answer:
final String pattern = "(?<!(^|[A-Z]))(?=[A-Z])|(?<!^)(?=[A-Z][a-z])";
for (String w : "TDMaturityReinvestOnNotSelected".split(pattern))
{
System.out.println(w);
}
And the ouput to show it running:
Edit: You'll need to reassemble the split words with spaces, but that should be trivial to work out.