Aggiunti alcuni esercizi di java.

This commit is contained in:
2023-03-08 19:00:28 +01:00
parent 5bdf6fbb5f
commit c038195ed5
584 changed files with 22842 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import java.util.Locale;
import java.util.regex.Pattern;
class SqueakyClean {
static String clean(String identifier) {
var result = identifier.replace(' ', '_')
.replaceAll("[α-ω]", "")
.replaceAll("\\p{C}", "CTRL")
.replaceAll("[^\\p{L}\\p{P}]", "");
var matcher = Pattern.compile("(.*)(-\\p{L})(.*)").matcher(result);
if (matcher.matches()) {
result = matcher.replaceAll(
matcher.group(1)
+ matcher.group(2).toUpperCase(Locale.ROOT).substring(1)
+ matcher.group(3)
);
}
return result;
}
}