/** * Replaces all occurrences of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceAllExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces the first occurrence of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceFirstExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces the first occurrence of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceFirstExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces the first occurrence of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceFirstExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<T>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces the first occurrence of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with the first occurrence of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceAll(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceFirstExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; if (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceAllExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<T>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceAllExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }
/** * Replaces all occurrences of the pattern with the specified list * of replacement items (can include matched groups). * @param replacement What to replace the matched sequence with * @return New list with all occurrences of the pattern replaced * @see #replaceFirst(java.util.List) * @see #replaceFirstExtended(java.util.List) * @see #replaceAllExtended(java.util.List) */ public List<T> replaceAllExtended(List<MatchReplacement<T>> replacement) { List<T> res = new ArrayList<>(); FindType oldFindType = findType; findType = FindType.FIND_NONOVERLAPPING; int index = 0; while (find()) { // Copy from current index to found index res.addAll(elements().subList(index, start())); for (MatchReplacement<T> r:replacement) { r.append(this, res); } index = end(); } res.addAll(elements().subList(index, elements().size())); findType = oldFindType; return res; }