• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

GTWebs

Tutorials, Tips, & Tricks for Web, Software, and App Developers

  • Tutorials
  • Web Dev
  • App Dev
  • Design
  • Blog

JavaScript Replace Text

You are here: Home / App Development / JavaScript Replace Text

App Development, Web Development · April 26, 2020

If you ever get into a situation where a string is received with some text that either shouldn’t be there, or is in there incorrectly, here’s a quick solution for that, use String.replace():

var text = "What the for an example";

alert("Before: " + text);


if (text && text.includes("What the")){
	text = text.replace("What the","Text");
}

alert("After: " + text);

Filed Under: App Development, Web Development Tagged With: javascript, tips, typescript

Bobby

Over the past 20 years or so I've been creating digital content, web sites, apps, and so much more. I created this blog to help developers, like you, in any way that I can because I know the struggle that exists while you build your dreams.

GTWebs can help you get your point across in an effective and interesting way. Contact us today to see how we can help you!

Previous Post: « Javascript When to use “let” and when to use “var”
Next Post: Automation: Automate Everything »

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Search

Recent

  • Don’t be scared of the cloud: AWS, Google Cloud Platform, DigitalOcean, Linode, VULTR
  • Start a Photography Website With Ease
  • Start Investing with Acorns in 3 Easy Steps
  • Fix Sound Won’t Play on MacBook Pro
  • How to Fix Skype Sound on a MacBook Pro After Connecting to TV

Footer

About

Become inspired to create your next awesome design whether it's code, art, or anything inbetween.

Social

  • Facebook
  • Instagram
  • LinkedIn
  • Medium
  • Pinterest
  • Tumblr
  • Twitter

Navigate

  • Tutorials
  • Web Dev
  • App Dev
  • Design
  • Blog

Subscribe

Copyright © 2025 GTStudios LLC ยท GTWebs | ThrillZing