-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSqueakyClean.java
More file actions
29 lines (22 loc) · 855 Bytes
/
Copy pathSqueakyClean.java
File metadata and controls
29 lines (22 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class SqueakyClean {
static String clean(String identifier) {
String task1 = identifier.replaceAll("\\s", "_");
Matcher matcher = Pattern.compile("-(\\w)").matcher(task1);
StringBuffer sBuffer = new StringBuffer();
while (matcher.find()){
matcher.appendReplacement(sBuffer, matcher.group(1).toUpperCase());
}
matcher.appendTail(sBuffer);
String task2 = sBuffer.toString();
String task3 = task2.replace("3","e")
.replace("0", "o")
.replace("4", "a")
.replace("7", "t")
.replace("1", "l")
.replace("3", "e");
String task4 = task3.replaceAll("[^a-zA-Z_]", "");
return task4;
}
}