Default TemplateGreen TemplateBlue TemplateRed TemplateGold TemplateBlue Gloss Template
Article Categories

Mycities Network
Java Scripts Examples and Tutorials
JavaScript replace Function

Wednesday Oct 11, 2006
The function replace can be used to replace a string with another string. A regular expression can be used to find the string.

<html>

<head>

<script type="text/javascript">

            var str = new String("Hello World")

            document.write(str+"<br/>")

            var regEx = new RegExp ('World', 'gi') ;

            str = str.replace(regEx, 'User')

            document.write(str)

</script>

</head>

<body></body>

</html>

Output

Hello World

Hello User



Comments : What do you think about this news?
No Comments yet.

POST COMMENT
Name
Message
  Post will be visible after admins approval
 
Members Login
User ID
Password
    Register
Forgot password?

SriLankaWebHosting.com
Just for (Rs.500) $5 per month

Your own domain name, 1GB Space, Unlimited Email Address, Sri Lankan Support & for more info call us.
077-989-5368, 072-829-9077



Terms And Conditions | Link Directory

Join Sri Lanka Banner Exchange | Resources - Free Link Exchange