Skip to content

Instantly share code, notes, and snippets.

@anova
Last active June 28, 2022 08:45
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save anova/6902147 to your computer and use it in GitHub Desktop.
Save anova/6902147 to your computer and use it in GitHub Desktop.
Capitalize, lowercase, uppercase for Turkish alphabet.
//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