Hi,
I have a string in the server side javascript and would like to replace all the occurrence of a sub-string with something else.
How can this be done?
Thanks,
Xiaoli
String replace all.
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 272
- Joined: Fri Dec 14, 2012 2:55 pm
- Location: Ottawa
- priyank
- Ebase User
- Posts: 10
- Joined: Tue Sep 18, 2012 6:02 pm
- Location: India
- Contact:
Hi Xiaoli,
The string replace function will help you to replace all occurrence of sub-string with whatever you desire.
Here's an example:
You can get more information from http://www.w3schools.com/jsref/jsref_replace.asp
Hope it helps.
The string replace function will help you to replace all occurrence of sub-string with whatever you desire.
Here's an example:
Code: Select all
var STRING = "This is a test string";
var NEW_STRING = STRING.replace(/is/g, "qq");
log(NEW_STRING); //Prints "Thqq qq a test string"
Hope it helps.
0 x
Regards,
Priyank
Priyank Panchal, B.Sc.(Comp.), M.C.A.
Email: priyank@schnellsolutions.com
Website: www.schnellsolutions.com
Priyank
Priyank Panchal, B.Sc.(Comp.), M.C.A.
Email: priyank@schnellsolutions.com
Website: www.schnellsolutions.com
Who is online
Users browsing this forum: No registered users and 25 guests