Grammar
Stringobject.replace (regexp/substr,replacement) parameter description
Regexp/substr required. The RegExp object that prescribes the substring or pattern to be replaced.
<script type= "text/web Effects" >
var str= "Visit 111cn.net!"
document.write (Str.replace (/111cn.net/, "111cn.net"))
</script>
To modify the size of a picture:
Replace the size in the picture properties with the following statement.
$ ("image"). attr ("src"). Replace ("size=60", "size=200");
Replace (target to replace, new value to replace)
Definitions and usage
Note that if the value is a string, it is used as the direct text pattern to retrieve, not first converted to the RegExp object.
Replacement required. A string value. Provides a function that replaces text or generates alternate text.
return value
A new string that is replaced with replacement for the first match of RegExp or after all matches have been made.
Description
The replace () method of the string Stringobject performs a find-and-replace operation. It will look for substrings in the stringobject that match the regexp, and then replace them with replacement. If RegExp has global flag G, then the Replace () method replaces all matching substrings. Otherwise, it replaces only the first matching substring.