R
Robert Crandal
I am working with strings that have the following format:
<last name> [title] <first name> [middle initial] 0000
(The [title] and [middle] are optional, so they might or
might not occur in a string! The title is usually "Jr." or
"Sr" or "III" or "II". Middle initial is only ONE character)
Here are some examples:
myVar = "Jones Jim R 0000"
myVar = "Filbert III Bobby 0000"
myVar = "Smith Jr James F 0000"
myVar = "Milton Brad 0000"
Can anyone think of a good strategy for parsing each of
the name tokens into their own variables?? I have 4 variables
named "myLast", "myTitle", "myFirst" and "myMiddle" where
I would like to store each token. What makes this difficult
is that the title and middle initial are optional and may not
exist in a string.
I'd appreciate any help here.
(BTW, assume that the data will be formatted exactly as
above with just one space between each token. There
also wont be any oddball situations, like an empty string)
Thanks!
<last name> [title] <first name> [middle initial] 0000
(The [title] and [middle] are optional, so they might or
might not occur in a string! The title is usually "Jr." or
"Sr" or "III" or "II". Middle initial is only ONE character)
Here are some examples:
myVar = "Jones Jim R 0000"
myVar = "Filbert III Bobby 0000"
myVar = "Smith Jr James F 0000"
myVar = "Milton Brad 0000"
Can anyone think of a good strategy for parsing each of
the name tokens into their own variables?? I have 4 variables
named "myLast", "myTitle", "myFirst" and "myMiddle" where
I would like to store each token. What makes this difficult
is that the title and middle initial are optional and may not
exist in a string.
I'd appreciate any help here.
(BTW, assume that the data will be formatted exactly as
above with just one space between each token. There
also wont be any oddball situations, like an empty string)
Thanks!