Search & Replace in javascript

August 1, 2007 at 4:50 am Leave a comment

<body>
<script language=”javascript”>
myvar=”test page”;                     //define a variable
sear=myvar.search(“page”);       //sear is a variable which holds result of search
if(sear==5)                                       // out put will be number
{
document.write(sear);
document.write(“<br>”);
oldvar=”hello there”;
newvar=oldvar.replace(“there”,”suresh”);       //replacing there by suresh
document.write(newvar);                      //output will be “hello suresh”
}
</body>

Entry filed under: Javascript. Tags: .

Window.open in js when popup is blocked Formating / multi formating strings in javascript

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Flickr Photos

The firsts lights

Lago di Braies

Survivor Mode

More Photos

Blog Stats

  • 705,777 hits

%d bloggers like this: