Regular expression, split string by capital letter but ignore TLA

((?<=[a-z])[A-Z]|[A-Z](?=[a-z]))

or its Unicode-aware cousin

((?<=\p{Ll})\p{Lu}|\p{Lu}(?=\p{Ll}))

when replaced globally with

" $1"

handles

TodayILiveInTheUSAWithSimon
USAToday
IAmSOOOBored

yielding

 Today I Live In The USA With Simon
USA Today
I Am SOOO Bored

In a second step you’d have to trim the string.

Leave a Comment