I remove the Space from the name i got from GetRealmName(), this seems to be the same what Blizzard does.
Ofcourse nobody can say what funny ideas they have next, perhaps changing case unpredictable.
At the moment i use following in my code (which you have then to concatenate with the player's name):
Lua Code:
string.gsub(GetRealmName(), "%s+", "")
PS: to get player and realm from sender i use following:
Lua Code:
player, realm = strsplit( "-", sender, 2 )