OK, so what is this string needed for. IOW, what is the constraint we are embracing here? For what will the new concatenated string be used. If we work back from the constraints (max number of characters, limited characters set, etc.) if may avoid having to re-do the code.
If the aim is to have a form of UID, consider this when stripping spaces and other non-A–Z:
“John A Smith” → “JohnASmith”
“John Asmitth” → “JohnAsmith”
In a case insensitive comparison, the two are the same despite different source string.