Play-Asia.com - Buy Video Games for Consoles and PC - From Japan, Korea and other Regions!

Javascript - String.replace()

 

Syntax

string.replace(regexpression, replacestring)

Description

The replace() method of an instance of the String object searches the string in which it is invoked for the regular expression passed to the method. The regular expression is made up of a pattern and flags that dictate what is to be matched. If and when a match is found, the method returns a new string with that match replaced with the replacement string passed to the method.

Example

<script language="JavaScript">
<!--

var myString = new String("Hello today");
var myRegExp = /today/g;

document.write(myString.replace(myRegExp, "tomorrow")); //result is 'Hello tomorrow''
//--> </script>

 

 
Visitor Review Write a review
No visitor review for this page yet
Write a review
Rating:
Text:
Name:
Email:
(optional)
 
Code:
 

Search:
Shopping Store Online
Clothes (25)
Gift shop (69)
Hand-made (27)
Luxuries (47)
Others (42)
Programming Tutorial
ASP (14)
CSharp (29)
HTML (10)
JavaScript
charAt method
charCodeAt method
concat method
indexOf method
lastIndexOf method
replace method
Photoshop (9)
PHP (11)
Entertainment
Anime (6)
E-Cards (12)
Games (20)
Music (7)