Replaces each character expression in a string that matches a string in a second character expression with the corresponding string in a third character expression.
JSV_replace(expS1, expS2, expS3)
expS1.replace(expS2, expS3)
Returns the string expS1, with every occurrence of substring expS2 replaced by expS3. If expS3 is not specified, all occurrences of expS2 are removed. If neither expS2 nor expS3 are specified, Replace returns null.
The replace function uses the following arguments.
Argument | Description |
expS1 | The string that is to be evaluated. |
expS2 | The string that is to be replaced. |
expS3 | The string that replaces the string found. |
n/a
The following lines of code
var testString1 = "Quiet feet make little noise on sleek ice", testString2 = "e", testString3 = "77";
document.write( "Replacing " + testString2.bold() +
" with " +
testString3.bold() +
" in " +
testString1.bold() +
" results in " +
JSV_replace(testString1,testString2,testString3).bold() );
produce
Copyright © 1998-2000 Roaring Fork Software. All rights reserved.