assuming we are talking about c++ strings - then string has some find member functions.
Like find, find_first_of, find_first_not_of
Check out the reference documentation on this site.
You can use ( a suitable one of these) to find the position of the !.
You can use the substr member function to extract the substring.
1. use find_first_of function to find the position of the ! within the original_string.
2. use substr function to get the substring (starting at position 0 to the point where the ! was found).
3. reassign the substring to the original_string. (original_string = substring).