Skip to content

Instantly share code, notes, and snippets.

@heinthanth
Last active September 1, 2019 04:36
Show Gist options
  • Save heinthanth/7d814a855e4d1a9dfc9a35fbc520311a to your computer and use it in GitHub Desktop.
Save heinthanth/7d814a855e4d1a9dfc9a35fbc520311a to your computer and use it in GitHub Desktop.
string replace
var str = "Hello, John Doe!";
var result = str.replace("John Doe", "Hein Thanth");
// now result is "Hello, Hein Thanth!";
var str = "Kali Linux is for Hackers. Also, Kali Linux, which is Debian based. Black Arch Linux too!";
var result = str.replace("Kali Linux", "Parrot Sec OS");
// now result is "Parrot Sec OS is for Hackers. Also, Kali Linux, which is Debian based. Black Arch Linux too!"
// although the word "Kali Linux" contain twice. Only Replace first Match
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment