You are viewing limited content. For full access, please sign in.

Question

Question

Quick Fields - Regular Expression

asked on September 18, 2015 Show version history

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

0 0

Answer

APPROVED ANSWER
replied on September 18, 2015

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.

3 0

Replies

replied on September 18, 2015

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.

1 0
APPROVED ANSWER
replied on September 18, 2015

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.

3 0
replied on September 24, 2015

Thank you Darrell and Miruna for the help.  Got it to work!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.