I hope this helps you. If you remove the characters in place you will have to shift the rest of the string one place to the left every time you remove a character, this is not very efficient. The following table describes the available trim methods. For example, removing ‘l’ from ‘hello’ prints ‘he’ rather than ‘heo’. Choose the type you’d like to provide: I thought that as the questioner was a beginner, he might learn much from decomposed version of problem.
Remove character from string
The best way is to have a second array that takes the filtered string. I am writing only logical part.