String replace all.

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

xren
Ebase User
Posts: 272
Joined: Fri Dec 14, 2012 2:55 pm
Location: Ottawa

String replace all.

#1

Postby xren » Mon May 13, 2013 7:53 pm

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
0 x

User avatar
priyank
Ebase User
Posts: 10
Joined: Tue Sep 18, 2012 6:02 pm
Location: India
Contact:

#2

Postby priyank » Tue May 14, 2013 7:22 am

Hi Xiaoli,

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"
You can get more information from http://www.w3schools.com/jsref/jsref_replace.asp

Hope it helps.
0 x
Regards,
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 11 guests