how to add hyphen before capital letter and decaptalize it in string in js code example Example: typescript space between capital letters s = s.replace(/([A-Z])/g, ' $1').trim()