What regular expression can I use in my Assign Token Value to change "Johnny B Good" to "Good, Johnny B" in my Quick Fields session?
Thanks,
Pete
What regular expression can I use in my Assign Token Value to change "Johnny B Good" to "Good, Johnny B" in my Quick Fields session?
Thanks,
Pete
To expand on what Darrell said, pattern matching does not have the ability to reverse the order or match groups, so you have to break out the data into its parts and rebuild it yourself.
On the other hand, Substitution can do it for you by allowing you to rearrange the match groups. The groups are named sequentially in the order they appear in the pattern. In the example below, I tweaked Darrell's pattern a bit to account for Johnny possibly not having a middle initial or having a hyphenated name
Since names are fairly free form, you might have to do some further tweaking to account for other variations, like hyphenated first names or multiple middle initials.
It would probably be easiest to take it as a whole then create three separate tokens. \w+\s\w+\s\w+ will get the whole thing then putting brackets around the \w+ you need will get the individual values.
(\w+)\s\w+\s\w+ will give you Johnny \w+\s(\w+)\s\w+ will give you B and \w+\s\w+\s(\w+) will give you Good. Then use those individual values to put the words in whatever order you need.
To expand on what Darrell said, pattern matching does not have the ability to reverse the order or match groups, so you have to break out the data into its parts and rebuild it yourself.
On the other hand, Substitution can do it for you by allowing you to rearrange the match groups. The groups are named sequentially in the order they appear in the pattern. In the example below, I tweaked Darrell's pattern a bit to account for Johnny possibly not having a middle initial or having a hyphenated name
Since names are fairly free form, you might have to do some further tweaking to account for other variations, like hyphenated first names or multiple middle initials.
Thank you Darrell and Miruna for the help. Got it to work!