# \[fmx\] Substituting characters from strings

**URL:** <https://forum.kirupa.com/t/fmx-substituting-characters-from-strings/115407>\
**Category:** Uncategorized\
**Created:** [July 8, 2004, 9:33am UTC](https://forum.kirupa.com/t/fmx-substituting-characters-from-strings/115407 "2004-07-08T09:33:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![borispc](https://avatars.discourse-cdn.com/v4/letter/b/ac8455/32.png) [@borispc](https://forum.kirupa.com/u/borispc)\
**Post date:** [July 8, 2004, 9:33am UTC](https://forum.kirupa.com/t/fmx-substituting-characters-from-strings/115407/1 "2004-07-08T09:33:00Z")

</div>

Hello!

I’d like to know how to substitute characters of strings.  
Let’s say I have…

my\_str=“Hello, Johny!, hello Dolly!”;

I want to substitute all “!” characters to “?”. How do we do this?

I am assuming that first we need to know the character position of the character we want to get rid of.

(we would loop this whole 3 step process until no more “!” characters were found in the string)

1. my\_str.indexOf("!"); returns 12  
[COLOR=DarkOrange]2) Now…how do I delete that character?[/COLOR]
2. The next step from there would probably be to use one of the methods String.substring() or String.slice to introduce the new character “?”;

What’s the best way to do this?
