Created
February 22, 2016 08:43
-
-
Save ThemeSama/d926d541717beb95f5b4 to your computer and use it in GitHub Desktop.
Permalik with Original Title
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
public static String strTranslate(String str) { | |
String from = "İıŞşÜüĞğÇçÖö "; | |
String to = "iissuuggccoo-"; | |
str = str.toLowerCase(); | |
//Dosya uzantısını siler | |
if( str.lastIndexOf('.') > 2 ) { | |
str = str.substring(0, str.lastIndexOf('.')); | |
} | |
char[] out = null; | |
for (int i = 0, len = str.length(); i < len; i++) { | |
char c = str.charAt(i); | |
int p = from.indexOf(c); | |
if (p >= 0) { | |
if (out == null) out = str.toCharArray(); | |
out[i] = to.charAt(p); | |
} | |
} | |
if(out != null) { | |
str = new String(out); | |
} | |
str = str.replaceAll("[^a-z0-9-]", ""); | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment