MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / replace

Method replace

ij/src/main/java/ij/macro/Functions.java:4068–4090  ·  view source on GitHub ↗
(String s1)

Source from the content-addressed store, hash-verified

4066 }
4067
4068 String replace(String s1) {
4069 s1 = getStringFunctionArg(s1);
4070 String s2 = getString();
4071 String s3 = getLastString();
4072 if (s2.length()==1) {
4073 StringBuilder sb = new StringBuilder(s1.length());
4074 for (int i=0; i<s1.length(); i++) {
4075 char c = s1.charAt(i);
4076 if (c==s2.charAt(0))
4077 sb.append(s3);
4078 else
4079 sb.append(c);
4080 }
4081 return sb.toString();
4082 } else {
4083 try {
4084 return s1.replaceAll(s2, s3);
4085 } catch (Exception e) {
4086 interp.error(""+e);
4087 return null;
4088 }
4089 }
4090 }
4091
4092 String trim() {
4093 if (interp.nextToken()=='=')

Callers 4

getStringFunctionMethod · 0.95
runStringFunctionMethod · 0.45
replacePlotMethod · 0.45
closeMethod · 0.45

Calls 9

getStringFunctionArgMethod · 0.95
getStringMethod · 0.95
getLastStringMethod · 0.95
charAtMethod · 0.80
replaceAllMethod · 0.80
lengthMethod · 0.65
appendMethod · 0.65
toStringMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected