RegEx expression to move first word to the end of a string?

I am calling an API that pulls in names in the following format:

SMITH JOHN

DOE JANE R.

BUSH GEORGE

CLINTON WILLIAM J.

Can I use the “find and replace with Regex” feature to move the first word in each string to the end of the string?

Hey @clark.nc :wave:

There are many regex formulas to do this. You can try this one: [SOLVED] How do you extract "first name" from "full name" field? - #17 by kenlaji

Then you can do a find and replace with the first name and replace it with nothing. Then add it to the end of the string.

Does that make sense?

How would I “add it to the end of the string”? The first part makes perfect sense… just not sure how to add it back into the end of the string…

@J805’s suggestion should work, but regex might not actually be necessary if each name string’s components are delimited by a single space. Instead, you could instead split each name string into a list, move the first item to the end, and rejoin the list with a space character…

The :split by() and join with just use a single space as the delimiter/join character.

3 Likes

Thank you! This worked perfectly.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.