Thanks Robert - yes I am able to replace patterns but just wondered If simple way to change a particular character in a string based on the character index?


Sent from my iPhone

On 14 Jul 2009, at 18:10, "Robert Leisle" <> wrote:

Does this not work for you?

// Change the first instance only
var myPattern:RegExp = /sh/;
// Change all instances
//var myPattern:RegExp = /sh/g;
var str:String = "She sells seashells by the seashore.";
trace(str.replace(myPattern, "sch"));
// She sells seaschells by the seashore.


-----Original Message-----
From: [mailto:flashcoders-] On Behalf Of Paul Steven
Sent: Tuesday, July 14, 2009 8:50 AM
To: 'Flash Coders List'
Subject: [Flashcoders] Equivalent of setCharAt to change a character in a string

Probably something really simple but can't for the life of me recall the syntax to change a particular character of a string.

For example if I have the word "Flash" and want to change the letter "a" to an "e", I was hoping there was a function like setCharAt(2, "e");

Btw I am coding in AS3.



Flashcoders mailing list

Flashcoders mailing list
Flashcoders mailing list

Reply via email to