Skip to content

Instantly share code, notes, and snippets.

@CrowderSoup
Created February 19, 2014 16:40
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save CrowderSoup/9095873 to your computer and use it in GitHub Desktop.
Save CrowderSoup/9095873 to your computer and use it in GitHub Desktop.
Replace all instances of a substring without Regex in JavaScript
var str = 'This is a test string.';
// Let's replace all spaces with ','
str = str.split(' ').join(',');
@AttafTerkawi
Copy link

Awesome!
how to replace (t) with (B)
in this example: (this is my Text)
the result is:
Bhis is my TexB

or:
this Is my text
try to replace (is)
???
thanks

@ytzlax
Copy link

ytzlax commented Aug 10, 2016

Thanks

@cayman2007
Copy link

Awesome, it works around the string length limit with the "replace" method.

@IgorMing
Copy link

INSANE!!!! Thank you for it!

@ramizdemiurge
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment