If you must do this parsing, I’m sure you’ll get lots of good suggestions here.
My suggestion is – don’t do this parsing.
Instead, create your input fields so that the information is already separated out. Have separate fields for title, first name, middle initial, last name, suffix, etc.