METHOD:  String::replace

object.replace(regexp, newSubStr)
object.replace(regexp, function)

This method is used to match a specifed regular expression against a string and replace any match with a new substring. The newSubStr argument can include certain RegExp properties. These are: $1 thru $9, lastMatch, lastParen, leftContext and rightContext (for details on the RegExp object's properties, go here). To perform a global match include the 'g' (global) flag in the regular expression and to perform a case-insensitive match include the 'i' (ignore case) flag.

The second argument can also be a function which is invoked after the match is performed and the result of which is used as the replacement string.

The following code uses the replace method to alter '' in the original string to the full URL for the DevGuru website and then uses the method to provide a hyperlink to the site.

myString = new String("Go to")
rExp = /;
newString = new String ("")
results = myString.replace(rExp,""))

Go to

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information