blob: d56584c3c1110e08c060b059d55e15e1ff7c3983 (
plain)
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
30
31
32
33
34
35
36
|
package kr.syeyoung.dungeonsguide.utils;
import java.text.DecimalFormat;
import java.util.List;
import java.util.regex.Pattern;
public class TextUtils {
private static final Pattern STRIP_COLOR_PATTERN = Pattern.compile("(?i)§[0-9A-FK-OR]");
private static final Pattern SCOREBOARD_CHARACTERS = Pattern.compile("[^a-z A-Z:0-9/'.]");
private static final Pattern INTEGER_CHARACTERS = Pattern.compile("[^0-9]");
public static String stripColor(String input) {
return STRIP_COLOR_PATTERN.matcher(input).replaceAll("");
}
public static String keepScoreboardCharacters(String text) {
return SCOREBOARD_CHARACTERS.matcher(text).replaceAll("");
}
public static String keepIntegerCharactersOnly(String text) {
return INTEGER_CHARACTERS.matcher(text).replaceAll("");
}
public static String join(List list, String delimeter) {
if (list.isEmpty()) return "";
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < list.size() - 1; i++) {
stringBuilder.append(list.get(i).toString()).append(delimeter);
}
stringBuilder.append(list.get(list.size() - 1).toString());
return stringBuilder.toString();
}
}
|