Simple And Fast String Find And Replace In Javascript

Posted By Weston Ganger

Here is a super simple way to find and replace in a string very easily. For rubyists, I would describe this as javascripts gsub method.

In this example we will replace 'string' with 'object':

"This string says string twice".split("string").join("object"); 
//==> This object says object twice

Related External Links:

Article Topic:Software Development - Javascript

Date:August 30, 2016