FileDocCategorySizeDatePackage
StrSubs.javaAPI DocExample842Sat Jan 13 18:05:36 GMT 2001com.darwinsys.util

StrSubs

public class StrSubs extends Object
A few String functions that are missing from String
author
Ian Darwin
version
$Id: StrSubs.java,v 1.1 2001/01/13 23:05:37 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)
A simple main for testing

		System.out.println(
			subst("lazy", "supine", "A quick bronze fox lept a lazy bovine"));
		System.out.println(
			subst("$DIR", "/home/ian", "$DIR/xxx"));
	
public static java.lang.Stringsubst(java.lang.String oldStr, java.lang.String newStr, java.lang.String inString)
Replace oldstr with newstr in instring


		int start = inString.indexOf(oldStr);
		if (start == -1) {
			return inString;
		}
		StringBuffer sb = new StringBuffer();
		sb.append(inString.substring(0, start));
		sb.append(newStr);
		sb.append(inString.substring(start+oldStr.length()));
		return sb.toString();