Search and replace text in a string

/ Published in: ActionScript
Save to your folder(s)

Copy this code and paste it in your HTML
  1. var newText:String = "The rain in Spain falls mainly on the plain";
  2. var splitText:Array = newText.split("Spain");
  3. newText = splitText.join("Barcelona");
  4. // outputs "The rain in Barcelona falls mainly on the plain"

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.