I am trying to manipulate a string and extract only certain data from it. I need to do this on a record retrieved from a database that gives me the full name of the person. I need to infer only the name from the string and save it as a variable. Is there a way I can do this?
Example: SQL query pulls the full field "Mary Ellen Jones" I need to extract only Jones from the string so that I can save it in a variable for further processing.
I thought maybe AnsiRightStr would work, but the problem is to give it an integer to pull to the right. Maybe a way of counting characters after the last space, allowing me to use AnsiRightStr (string, int) for this? Any help is generally appreciated.
Additional thought: would replace the spaces with say :: separator and then parse this data into a Stringlist, after which it would be possible to pull out the last index of the list of strings?
So far, several valid parameters have been presented. None of them turn to the situation if they say that this name is “Something like” John St. James Jr. “Is this impossible?
Jamesw
source share