List of utility methods to do String Substritute
String | substitute(String strSource, String strValue, String strBookmark) This function substitutes all occurences of a given bookmark by a given value StringBuffer strResult = new StringBuffer(); int nPos = strSource.indexOf(strBookmark); String strModifySource = strSource; while (nPos != -1) { strResult.append(strModifySource.substring(0, nPos)); strResult.append(strValue); strModifySource = strModifySource.substring(nPos + strBookmark.length()); nPos = strModifySource.indexOf(strBookmark); ... |
String | substitute(String template, String[] values) Performs variable substitution on a template string. StringBuilder buff = new StringBuilder(); int maxUsed = 0; char[] t = template.toCharArray(); for (int i = 0; i < t.length; i++) { if (t[i] == '$' && i < t.length - 1) { if (t[i + 1] == '$') { buff.append('$'); i++; ... |
String | substitute(String txt, String pattern, String sub) substitute int o = 0; for (;;) { o = txt.indexOf(pattern, o); if (o < 0) break; txt = txt.substring(0, o) + sub + txt.substring(o + pattern.length()); o += sub.length(); return txt; |
String | substituteAll(String regexp, String subst, String target) substitute All return target.replaceAll(regexp, subst);
|
String | substituteBlanks(String s, String subst) substitute Blanks StringBuffer sb = new StringBuffer(); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) != ' ') { sb.append(s.charAt(i)); } else { sb.append(subst); return sb.toString(); |
String[] | substituteCommandLine(String[] parsedCommandLine, String file1Name, String file2Name, String display1, String display2) substitute Command Line for (int i = 0; i < parsedCommandLine.length; i++) { if (parsedCommandLine[i].equals("file1Name")) { parsedCommandLine[i] = file1Name; } else if (parsedCommandLine[i].equals("file2Name")) { parsedCommandLine[i] = file2Name; } else if (parsedCommandLine[i].equals("display1")) { parsedCommandLine[i] = display1; } else if (parsedCommandLine[i].equals("display2")) { ... |
String | substituteEnvironmentVariables(String str, String prefix, String suffix) substitute Environment Variables StringBuilder buffer = new StringBuilder(str); int prefixLength = prefix.length(); int index = 0; while (index < buffer.length()) { index = buffer.indexOf(prefix, index); if (index < 0) break; index += prefixLength; ... |
String | substituteHex(String aString) Substitutes hex values in aString and convert them to operating system char equivalents in the return string.
if (aString == null) return null; StringBuffer buffer = new StringBuffer(); String rest = aString; int i = rest.indexOf(HEX_OPEN); while (i > -1) { int j = rest.indexOf(HEX_CLOSE, i + HEX_OPEN.length()); if (j > -1) { ... |
String | substituteInvalidChars(String str) substitute Invalid Chars str = str.replace(' ', '_'); str = str.replace('.', '_'); return str; |
String | substituteJobID(String path) substitute Job ID if (path == null) { return null; return path.replace("%j", "$PBS_JOBID"); |