List of utility methods to do Regex String Replace Last
String | replaceLast(String foo, String regex, String replacement) Sostituisce nella stringa foo l'ultima occorrenza della regex con replacement (es. Pattern p = Pattern.compile(regex); Matcher m = p.matcher(foo); int start = -1; int end = -1; while (m.find()) { start = m.start(); end = m.end(); if (start < 0) { return foo; return foo.substring(0, start) + replacement + foo.substring(end); |
String | replaceLast(String input, String regex, String replacement) replace Last Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(input); if (!matcher.find()) { return input; int lastMatchStart; do { lastMatchStart = matcher.start(); ... |
String | replaceLast(String string, String regex, String replacement) Works like String.replaceFirst, but replaces the last instance instead. if (regex == null) { return string; if (string == null) { return null; if (regex.length() > string.length()) { return string; ... |