String.replace()

Actionscript:
  1. var words:String = "ActionSnippet.com is a website. ActionSnippet.com is a blog.";
  2.  
  3. // outputs: "ActionSnippet.com is a website. ActionSnippet.com is a blog.";
  4. trace(words);
  5.  
  6. // the "/g" tells it to replace all instances of ActionSnippet.com
  7. words = words.replace(/ActionSnippet.com/g, "SomeWebsite.com");
  8.  
  9. // outputs: SomeWebsite.com is a website. SomeWebsite.com is a blog.
  10. trace(words);

Just a quick response to a student question.

This entry was posted in string manipulation, strings and tagged , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*