Sorry, caught a typo. Mytext1 is correctly replaced because only one instance of the character (space) is in the string.
This deals with the correct characters but only does the first instance of the character so the output is: 'Mytext1' 'Mytext 2' (wrong) 'Mytext-3' (wrong) 'My_text4' 'My!text5'