Skip to content

Instantly share code, notes, and snippets.

@Shilo
Created November 5, 2020 09:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shilo/3827de1c4532bb1fe22c34bb11cce452 to your computer and use it in GitHub Desktop.
Save Shilo/3827de1c4532bb1fe22c34bb11cce452 to your computer and use it in GitHub Desktop.
Javascript to replace "~~" to html strikethrough tags.
let string = "~~test string~~";
let i = 0;
string = string.replace(new RegExp("~~", 'g'), c => ++i % 2 ? "<s>" : "</s>");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment