Trim names

This commit is contained in:
M66B 2022-08-29 16:47:53 +02:00
parent 4d67d89528
commit 197762b9a3
2 changed files with 18 additions and 0 deletions

View File

@ -170,6 +170,9 @@ public class EntityAnswer implements Serializable {
}
}
first = Helper.trim(first, ".");
last = Helper.trim(last, ".");
text = text.replace("$name$", fullName == null ? "" : Html.escapeHtml(fullName));
text = text.replace("$firstname$", first == null ? "" : Html.escapeHtml(first));
text = text.replace("$lastname$", last == null ? "" : Html.escapeHtml(last));

View File

@ -2151,6 +2151,21 @@ public class Helper {
return (c == '.' /* Latin */ || c == '。' /* Chinese */);
}
static String trim(String value, String chars) {
if (value == null)
return null;
for (Character kar : chars.toCharArray()) {
String k = kar.toString();
while (value.startsWith(k))
value = value.substring(1);
while (value.endsWith(k))
value = value.substring(0, value.length() - 1);
}
return value;
}
// Files
static {