-
-
Save ionurboz/2647febd617af94c2de9a9d59e7fd3a5 to your computer and use it in GitHub Desktop.
Capitalize, lowercase, uppercase for Turkish alphabet.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://stackoverflow.com/a/1026087/181295 | |
String.prototype.turkishUpperCase = function () { | |
return this.replace(/ğ/g, 'Ğ') | |
.replace(/ü/g, 'Ü') | |
.replace(/ş/g, 'Ş') | |
.replace(/ı/g, 'I') | |
.replace(/i/g, 'İ') | |
.replace(/ö/g, 'Ö') | |
.replace(/ç/g, 'Ç') | |
.toUpperCase(); | |
};//String.turkishUpperCase | |
String.prototype.turkishLowerCase = function () { | |
return this.replace(/Ğ/g, 'ğ') | |
.replace(/Ü/g, 'ü') | |
.replace(/Ş/g, 'ş') | |
.replace(/I/g, 'ı') | |
.replace(/İ/g, 'i') | |
.replace(/Ö/g, 'ö') | |
.replace(/Ç/g, 'ç') | |
.toLowerCase(); | |
};//String.turkishLowerCase | |
String.prototype.turkishCapitalize = function() { | |
return this.charAt(0).turkishUpperCase() + this.slice(1).turkishLowerCase() | |
};//String.turkishCapitalize | |
String.prototype.turkishCapitalizeWords = function() { | |
var a = this.split(' '); | |
for(var i=0;i < a.length; i++) a[i] = a[i].turkishCapitalize(); | |
return a.join(' '); | |
};//String.turkishCapitalizeWords |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment