Use a function in a replace to change the strings:
HmtlStr = HmtlStr.replace(
/([A-Z])([A-Z]+)/g,
function(a,m1,m2) {
return m1 + m2.toLowerCase();
}
);
Edit:
The built in toLowerCase
method handles most characters, you just have to include them in the set in the regular expression ([A-ZÖİŞÜĞÇ]
) so that they are handled. To handle the few characters that the built in method doesn't cope with, you can make a function that replaces those first:
function localLowerCase(str) {
str = str.replace(
/İ/g,
function(m){
var i = "İ".indexOf(m);
return i != -1 ? "ı"[i] : m;
}
);
return str.toLowerCase();
}
You can easily add more characters for the function to handle by adding them in the /İ/
pattern, the "İ"
string and the replacement in the "ı"
string.