This isn't quite right - it will find any set of one or more uppercase letters (rather than word) and then replace other sequences of uppercase letters with the first sequence found. So if you run this on
ABI Technik
Accounting, Economics and Law
You get
Abi Abiechnik
Accounting, Aconomics and Aaw
My one-liner to find all words with no lowercase letters and converting to titlecase is:
forEach(value.split(' '),v,if(isNonBlank(v.match(/([^a-z]*)/)[0]),toTitlecase(v.match(/([^a-z]*)/)[0]),v)).join(" ")
Splits string into array of words (split on space), checks if word contains no lowercase and if so converts to titlecase, joins array back together into string using space as join. To use 'only uppercase' rather than 'no lowercase' you can use the very similar
forEach(value.split(' '),v,if(isNonBlank(v.match(/([A-Z]*)/)[0]),toTitlecase(v.match(/([A-Z]*)/)[0]),v)).join(" ")
Owen