Home > Java Scripts Examples and Tutorials > JavaScript replace() Method
Today's News
Maldives president resigns amid protests
UNP also protest at Hulftsdorp
Indian Coast Guard nabs 5 Lankan fishing boats
SL wins toss
SF brought to court
Get well soon, SLC tells Yuvi
We need democracy plus; Ranil
White flag appeal postponed
UNP DNA join hands in protest
India still ‘world class’ insists Mathews
SL to market Ayurveda drugs
Nine hand grenades found near Aluth Kade Court
Hirunika to join active politics
IPL teams splash the cash for Mahela and Murali
Anoma to lead protest to free SF
US diplomats heading to Sri Lanka
CID probing double murder in Kahawatta
Dr. R.H.S. Samaratunga appointed Sec to Petroleum Ministry
A/L fiasco - Probe team’s mandate limited
Three including police officer injured in Maligawatta shootout
Love & Relationship
Are you in Love?
10 Top Sex Secrets Men won't Tell
Top 10 — Female Turn Ons
10 Commandments for good wives
How to live a happy and satisfied Life
Did I marry the right person?
Are You Happy
Alcohol makes men BETTER in the bedroom, scientists claim
Too busy for Love Making?
Have you gone off sex?
Love Isn't Blind
Are You A Lazy Lover?
5 Secret Relationship Resolutions
Are You Getting Attracted To Another Person?
Do you feel loved?
JavaScript replace() Method
The replace() method is used to replace some characters with some other characters in a string. stringObject.replace(findstring,newstring)
Monday, Dec 31, 2007 | 1718 Views | Comments [View/Post]
|
stringObject.replace(findstring,newstring) findstring: Required. Specifies a string value to find. To perform a global search add a 'g' flag to this parameter and to perform a case-insensitive search add an 'i' flag newstring: Required. Specifies the string to replace the found value from findstring Note: In the following example the word Microsoft will not be replaced (because the replace() method is case sensitive): <script type="text/javascript"> var str="Visit Microsoft!"; document.write(str.replace(/Microsoft/, "W3Schools")); </script> Example 2 - Case-insensitive Search In the following example we will perform a case-insensitive search, and the word Microsoft will be replaced: <script type="text/javascript">var str="Visit Microsoft!"; document.write(str.replace(/microsoft/i, "W3Schools")); </script> Example 3 - Global Search <script type="text/javascript"> var str="Welcome to Microsoft! "; str=str + "We are proud to announce that Microsoft has "; str=str + "one of the largest Web Developers sites in the world."; document.write(str.replace(/Microsoft/g, "W3Schools")); </script> Example 4 - Global and Case-insensitive Search In the following example we will perform a global and case-insensitive match, and the word Microsoft will be replaced each time it is found, independent of upper and lower case characters: <script type="text/javascript"> var str="Welcome to Microsoft! "; str=str + "We are proud to announce that Microsoft has "; str=str + "one of the largest Web Developers sites in the world."; document.write(str.replace(/microsoft/gi, "W3Schools")); </script> |
Comment on this article
Guidelines: You must register with a social media account such as Facebook, Twitter, Yahoo, etc. to comment on this story. Click on the "Login" button below to choose your login account of choice. We welcome your thoughts, but this is not an open forum. For the sake of all readers, please refrain from the use of obscenities, personal attacks or racial slurs. All comments must remain on topic and cyber bullying will not be tolerated. All comments are subject to our terms of service. Comments that do not comply may be removed. Repeat offenders will lose commenting privileges.
Guidelines: You must register with a social media account such as Facebook, Twitter, Yahoo, etc. to comment on this story. Click on the "Login" button below to choose your login account of choice. We welcome your thoughts, but this is not an open forum. For the sake of all readers, please refrain from the use of obscenities, personal attacks or racial slurs. All comments must remain on topic and cyber bullying will not be tolerated. All comments are subject to our terms of service. Comments that do not comply may be removed. Repeat offenders will lose commenting privileges.
Follow @MulPituwa
News Categories
Accidents and Incidents
Art and Society
Business and Finance
Education and Employment
Environment and Development
Help and Aid
Science and Technology
Security and Politics
Share Market and Exchange Rates
Sports and Entertainment
Tourism and Foreign Affairs
Women and Health
News Other Language
World News
Movie News
Information
Information
Women and Health
Food Recipes
Love and Relationship
Web and IT
AJAX Examples and Tutorials
Java Scripts Examples and Tutorials
PHP Scripts Examples and Tutorials
Travel News
Most Populer
Men want good-looking women
Making sex exciting
Duminda unmasked by Anarkali
Too busy for Love Making?
Srikanth Vandana got a Baby Boy-Father and Son Born on Same Day!
Anjali’s days with Bharathiraja and K. Balachandar
Have you gone off sex?
Sex and Shoes
Dirty Talk!
Happy Birthday Surya
Alcohol makes men BETTER in the bedroom, scientists claim
Sexless Marriages
Are You A Lazy Lover?
5 Secret Relationship Resolutions
Outsider Played Actress Sneha Hot Sexy Hip Cheap Photos?

































