MCPcopy Create free account
hub / github.com/ReadyTalk/avian / replace

Method replace

classpath/java/util/regex/Matcher.java:54–81  ·  view source on GitHub ↗
(String replacement, int limit)

Source from the content-addressed store, hash-verified

52 }
53
54 protected String replace(String replacement, int limit) {
55 reset();
56
57 StringBuilder sb = null;
58 int index = 0;
59 int count = 0;
60 while (count < limit && index < input.length()) {
61 if (find(index)) {
62 if (sb == null) {
63 sb = new StringBuilder();
64 }
65 if (start > index) {
66 sb.append(input.subSequence(index, start));
67 }
68 sb.append(replacement);
69 index = end;
70 ++ count;
71 } else if (index == 0) {
72 return input.toString();
73 } else {
74 break;
75 }
76 }
77 if (index < input.length()) {
78 sb.append(input.subSequence(index, input.length()));
79 }
80 return sb.toString();
81 }
82
83 public int start() {
84 return start;

Callers 2

replaceAllMethod · 0.95
replaceFirstMethod · 0.95

Calls 7

resetMethod · 0.95
findMethod · 0.95
appendMethod · 0.95
toStringMethod · 0.95
lengthMethod · 0.65
subSequenceMethod · 0.65
toStringMethod · 0.65

Tested by

no test coverage detected