MCPcopy Create free account
hub / github.com/antlr/codebuff / replaceFrom

Method replaceFrom

output/java_guava/1.4.19/CharMatcher.java:840–854  ·  view source on GitHub ↗

Returns a string copy of the input character sequence, with each character that matches this matcher replaced by a given replacement character. For example: CharMatcher.is('a').replaceFrom("radar", 'o') ... returns "rodor". The default implementation uses {@link

(CharSequence sequence, char replacement)

Source from the content-addressed store, hash-verified

838
839
840 public String replaceFrom(CharSequence sequence, char replacement) {
841 String string = sequence.toString();
842 int pos = indexIn(string);
843 if (pos == -1) {
844 return string;
845 }
846 char[] chars = string.toCharArray();
847 chars[pos] = replacement;
848 for (int i = pos + 1; i < chars.length; i++) {
849 if (matches(chars[i])) {
850 chars[i] = replacement;
851 }
852 }
853 return new String(chars);
854 }
855
856 /**
857 * Returns a string copy of the input character sequence, with each character that matches this

Callers 1

InternetDomainNameMethod · 0.45

Calls 7

indexInMethod · 0.95
matchesMethod · 0.95
removeFromMethod · 0.95
toStringMethod · 0.65
toCharArrayMethod · 0.45
lengthMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected