MCPcopy Create free account
hub / github.com/banq/jivejdon / replace

Method replace

lib/jf/src/main/java/com/jdon/util/StringUtil.java:147–172  ·  view source on GitHub ↗
(String s, String oldSub, String newSub)

Source from the content-addressed store, hash-verified

145 }
146
147 public static String replace(String s, String oldSub, String newSub) {
148 if ((s == null) || (oldSub == null) || (newSub == null)) {
149 return null;
150 }
151
152 int y = s.indexOf(oldSub);
153
154 if (y >= 0) {
155 StringBuilder sb = new StringBuilder();
156 int length = oldSub.length();
157 int x = 0;
158
159 while (x <= y) {
160 sb.append(s.substring(x, y));
161 sb.append(newSub);
162 x = y + length;
163 y = s.indexOf(oldSub, x);
164 }
165
166 sb.append(s.substring(x));
167
168 return sb.toString();
169 } else {
170 return s;
171 }
172 }
173
174 public static String replace(String s, String[] oldSubs, String[] newSubs) {
175 if ((s == null) || (oldSubs == null) || (newSubs == null)) {

Callers 15

createShortMessageMethod · 0.95
createShortMessageMethod · 0.95
createShortMessageMethod · 0.95
createShortMessageMethod · 0.95
convertContentMethod · 0.95
highlightCodeMethod · 0.95
highlightCodeMethod · 0.95
convertTagsMethod · 0.95
parseQuotesMethod · 0.95
reformatTextMethod · 0.95
getLineAsCharMethod · 0.95
escapeHTMLMethod · 0.95

Calls 2

appendMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected