I am implementing a heuristic for splitting names up into relevant fields (I know it would be easier to received them separated but I’m not). I need to remove all of the ‘.’ characters in the string first, and then split where there are spaces in the string.
Why isn’t this removing the ‘.’ in for example Mr. John Doe
public void SplitNamesAndRemovePeriods()
{
char[] period = {'.'};
nameInFull = nameInFull.TrimEnd(period);
string[] allNames = nameInFull.Split(' ');
PrintNames();
}
Thanks
TrimEndremoves all trailing occurrences of a set of characters specified in an array from the current String object.Try: