I would like some help parsing a string of someones name. I would like to take the string and remove it so that only the first name will be in the string.
Suppose I have a name like this
Mr. John Doe
John Smith.
In both cases I would like to only get the first name of the string and delete all other characters.
EDITED:
So for both strings after they have been parsed will on have John in them
I was wondering if there was a way to do this problem with regex.
Use split to place the parts of the name into an array.
Examine the first element to see if it’s a title (“mr., mrs., dr., or miss”). If not, take it. Otherwise, take the next element and stop.
EDIT: This is an answer to the OPs original question.
EDIT 2: Please explain any down-votes. As stated, the OP changed his question after I answered it.