Simple And Fast String Find And Replace In Javascript

Posted by Weston Ganger on August 30, 2016

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:

Posted in Javascript and Tagged with replace 

Want me to help develop your next project or application?

Contact Us

Specializing in Ruby-on-Rails, Javascript, Multi-Platform Electron Desktop Apps and Hybrid Cordova Mobile Apps.

Recommended Posts