It is easy. To convert the string to lower case:
To remove whitespaces at the beginning and the end.
Check if a string starts with something:
if (str.startsWith( "something" ))
// Code here, lol
The last one I am not sure about, but you could replace the ! character with nothing like this:
str = str.replace("!", "");
And then check the length with the .length() method of the string. Of course, there may be better ways and I do not have the time to actually check if it works now because I am in a hurry. Hope this cleared things up.