replace method

ParamString replace(
  1. String word,
  2. String replacement
)

Implementation

ParamString replace( String word, String replacement ){
	int end = word.length;
	if( end > 0 ){
		int top = 0;
		while( top < str().length ){
			if( str().substring( top, end ) == word ){
				String forward = (top > 0) ? str().substring( 0, top ) : "";
				String after   = (end < str().length) ? str().substring( end ) : "";
				set( forward + replacement + after );
				top += replacement.length;
				end += replacement.length;
			} else {
				top++;
				end++;
			}
		}
	}
	return this;
}