How can I convert a string either like \'helloThere\' or \'HelloThere\' to \'Hello There\' in JavaScript?
var text = 'helloThereMister';
var result = text.replace( /([A-Z])/g, " $1" );
var finalResult = result.charAt(0).toUpperCase() + result.slice(1);
console.log(finalResult);
capitalize the first letter - as an example.
Note the space in " $1".
EDIT: added an example of capitalization of the first letter. Of course, in case the first letter is already capital - you would have a spare space to remove.