I am using the filter below to convert the string to camel case. In addition to this I do not want a string with alphanumeric characters to be converted to camelcase.
For example:
If the input is "HELLO I AM INDIA1237"
The output has to be "Hello I Am INDIA1237"
my filter is as below:
angular.module('app')
.filter('titleCase', function() {
return function(input) {
input = input || '';
input = input.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();}); //convert to camelcase
return input.replace(/[A-Za-z0-9 ]/, function(txt){return txt.toUpperCase();}); //retain alphanumeric string in uppercase
};
});
the second condition does not seem to be working. Can anyone please help.