|There's more than one way to do things|
Re: How do I cut single characters out of a stringby Not_a_Number (Prior)
|on Jan 13, 2012 at 20:36 UTC||Need Help??|
Ok, you've had three replies* (at the time of writing), all showing you how to remove '1' from a string.
Now, I might be wrong here (in which case read no further), but your use of a variable $getchar suggests that it might not be a known character that you want to remove from the string (and apparently save to a variable), but a character at a given position in the string.
However, you say:
now I need to only cut number 1 from the middle
Which rather militates against my analysis:
1. Your example string is 14 characters long, and therefore has no single middle character.
2. The middle two characters are 'ng', but you say you want 'number 1 from the middle'.
Whatever your real requirement, the following code removes and saves the middle character of a string if its length is odd, or the first of the two middle characters if its length is even:
* One canonical, one rather needlessly complicated, and one that removes all '1's willy nilly.