CamelCaseString to Space Separated String

groovy> print 'CamelCaseString'.replaceAll(/([A-Z][a-z]*)/, '$1 ').trim()
Camel Case String

There is probably a better regex approach that does not a space to the final word, and thus remove the need for a trim, but this is quick and easily embeddable anywhere, for example, in a jasper report groovy expression. Winking smile

Leave a Reply