MCPcopy Create free account
hub / github.com/banq/jdonframework / remove

Method remove

src/main/java/com/jdon/util/StringUtil.java:123–145  ·  view source on GitHub ↗
(String s, String remove, String delimiter)

Source from the content-addressed store, hash-verified

121 }
122
123 public static String remove(String s, String remove, String delimiter) {
124 if ((s == null) || (remove == null) || (delimiter == null)) {
125 return null;
126 }
127
128 if (UtilValidate.isNotEmpty(s) && !s.endsWith(delimiter)) {
129 s += delimiter;
130 }
131
132 while (contains(s, remove, delimiter)) {
133 int pos = s.indexOf(delimiter + remove + delimiter);
134
135 if (pos == -1) {
136 if (s.startsWith(remove + delimiter)) {
137 s = s.substring(remove.length() + delimiter.length(), s.length());
138 }
139 } else {
140 s = s.substring(0, pos) + s.substring(pos + remove.length() + delimiter.length(), s.length());
141 }
142 }
143
144 return s;
145 }
146
147 public static String replace(String s, String oldSub, String newSub) {
148 if ((s == null) || (oldSub == null) || (newSub == null)) {

Callers

nothing calls this directly

Calls 3

isNotEmptyMethod · 0.95
containsMethod · 0.95
startsWithMethod · 0.80

Tested by

no test coverage detected