Help

Re: Need help removing a word, and also extra space between other words

1825 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Damon_Talbot
7 - App Architect
7 - App Architect

I have a field that is bringing in names using the web clipper block. The problem I am having is the names from the site come in with additional header, and extra space between them. Is there a way to clean this up in a formula or in the web clipper on import? Here is the example:

Clients:  Bob Jenkins     Sarah Hunter

I need it to look like this:

Bob Hunter, Sarah Hunter

Thanks as always!

15 Replies 15

With a formula you could do SUBSTITUTE(SUBSTITUTE({Field}, " ", ", "), "Clients: ", "")

Nope, that didn’t work. I get this as the result:

Clients: , Bob, Jenkins,   , Sarah, Hunter

Is Web Clipper always adding 2 spaces after “Clients:” and 5 spaces between each client name? If so then try:

TRIM(SUBSTITUTE(SUBSTITUTE({Field}, "Clients:", ""), **" "**, ", "))

The part with double asterisks around it, make sure there are 5 spaces between the quotes, don’t actually include asterisks in your formula.

Same issue I’ve been having… for some reason it does not remove the space between names or add the comma. I’ve been trying combinations of trim, substitute, replace, and banging my head.

Bob Jenkins    Sarah Hunter

Because this forum truncates double spaces I can’t really tell if its the case, but when you’re putting the formula in Airtable are you including the right number of spaces?

Yes, ive checked the spaces

The formula works for me. Screen Shot 2020-05-22 at 3.40.23 PM

All I can say is double checking the number of spaces included in the formula.

Screen Shot 2020-05-22 at 3.41.30 PM

Perhaps the number of spaces between names isn’t that predictable. Here’s an option that’s a little more loosely defined. It’s split into two formulas because the second one uses the first one twice.

Screen Shot 2020-05-22 at 6.03.01 PM

The {Step 1} formula removes the “Clients:” header, replaces any instance of two consecutive spaces with a block of 30 spaces, and trims the result. We’re left with just the names and a big gap of spaces that’s guaranteed to be at least 30 spaces wide (most likely bigger).

TRIM(SUBSTITUTE(SUBSTITUTE(Original, "Clients:", ""), "  ", REPT(" ", 30)))

(BTW: depending on how you add code to your post, you can get the forum parser to leave larger space blocks alone. I used the 4-space indentation method above. If you wrap your code in matching graves-triplets, large blocks of spaces are condensed. Learned something new today!)

Here’s what that {Step 1} output looks like with the field value expanded:

Screen Shot 2020-05-22 at 6.14.38 PM

The second formula takes that result and extracts the names by removing 30-character chunks from the beginning and end, and adding the comma in the middle. Because we’re assuming that no name will be 30 characters long, each 30-character extraction returns a name and a portion of the at-least-30-spaces-wide block between names, but none of the other name.

TRIM(LEFT({Step 1}, 30)) & ", " & TRIM(RIGHT({Step 1}, 30))

If you want all of this in a single formula, here you go:

TRIM(LEFT(TRIM(SUBSTITUTE(SUBSTITUTE(Original, "Clients:", ""), "  ", REPT(" ", 30))), 30)) & ", " & TRIM(RIGHT(TRIM(SUBSTITUTE(SUBSTITUTE(Original, "Clients:", ""), "  ", REPT(" ", 30))), 30))

Will clients always be two names? Justin’s formula solves the unpredictability of variable numbers of spaces, but you may run into issue if you have 3 or more clients