# String character detection

**URL:** <https://forum.kirupa.com/t/string-character-detection/241405>\
**Category:** Uncategorized\
**Created:** [October 13, 2007, 11:54am UTC](https://forum.kirupa.com/t/string-character-detection/241405 "2007-10-13T11:54:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pete2004](https://avatars.discourse-cdn.com/v4/letter/p/96bed5/32.png) [@pete2004](https://forum.kirupa.com/u/pete2004)\
**Post date:** [October 13, 2007, 11:54am UTC](https://forum.kirupa.com/t/string-character-detection/241405/1 "2007-10-13T11:54:07Z")

</div>

hi,

Can anyone help me?  
I would like to know if there is a way to detect from [COLOR=“Blue”]star[/COLOR] variable second [COLOR=“Red”]a[/COLOR] and [COLOR=“red”]b[/COLOR] in the following code? I want to compose code to omit first [COLOR=“Red”]a[/COLOR] and [COLOR=“red”]b[/COLOR] and detect only second [COLOR=“Red”]a[/COLOR] and [COLOR=“red”]b[/COLOR]. At the moment it detects both - first and second. And once the second [COLOR=“red”]a[/COLOR] and [COLOR=“red”]b[/COLOR] is detected I want it to be replaced by [COLOR=“red”]g[/COLOR] and [COLOR=“red”]h[/COLOR] so the [COLOR=“blue”]star[/COLOR] variable will have following string: “a b c d e f g h”. Here is the code:

```auto
// there are 2 "a" and "b" letters in the string
var star:String = "a b c d e f a b";
for (var l = 0; l<15; l++) {
	switch (star.charAt(l)) {
	case "a" :
	case "b" :
		trace("detected:"+star.charAt(l));
		break;
	}
}

```

thanks a lot
