I am using a shortcut to extract personal details from a phot. I have extacted out the line with their name, and it is in the format such as:
SMITH, MS JENNY ANGELA
I am trying to use the MATCH command to get the firstname and have
^*(.+),\s
as i thought that you could use brackets in a RegExp to return part of the results of the expression, but when I look at the match results I will get
SMITH,
(with the comma)
The reson I am using .+ to match is I want to handle names such as O’HARA and FANCY-SURNAME as well as more typical single word surnames.
Is there an easier way that I am just overlooking? I can’t really find a lot of detailed explanation or examples for this when I actually want to return more than one piece of data from a single match statement.
You are matching. Groups (sets in parentheses) are for substitutions. I think you would always have to use a two step process if you are relying on the comma for a match to then remove the comma with a subsequent step.
Not sure what you mean here. If I match first and last names, aren’t I getting back what I already have? And if I split on comma, I still need to trim out the prefix
eg:
SMITH, MS JENNY ANGELA
Split on comma, wont I get
“SMITH”
“MS JENNY ANGELA”
and still need to parse out the first name?
Sorry. Forgot that was your example. Yes, you’re right unless you remove the comma and split by spaces I guess. That would be three steps to give access to the two items.