Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

How to extract a word from a string?

Topic Labels: Formulas
Solved
Jump to Solution
536 4
cancel
Showing results for 
Search instead for 
Did you mean: 

I could use some assistance with extracting a word from a string.

Here is an example of the string.
200 East Broadway #Z001 (Jacob to Seymore)

This is the formula that almost has what I need but missing something.
MID({Transaction Name},
SEARCH("#",{Transaction Name}),
SEARCH("#",{Transaction Name},
SEARCH(" “,{Transaction Name})) -
SEARCH(” ",{Transaction Name}))

I’m trying to extract the apartment number (#Z001) from the string.

Thanks in advance to anyone that tries to help with a solution.

1 Solution

Accepted Solutions

This could be greatly simplified by using regular expressions and the REGEX_EXTRACT() function:

IF({Transaction Name}, REGEX_EXTRACT({Transaction Name}, "#[^\\s]+"))

Screen Shot 2021-09-03 at 11.07.07 PM

That extracts everything beginning with the # symbol up to—but not including—the next whitespace in the string. I wrapped the IF() function around it to prevent an #ERROR result if {Transaction Name} is empty.

See Solution in Thread

4 Replies 4

I posted the question too soon as I now have a working formula.

TRIM(MID(SUBSTITUTE({Transaction Name}," “,REPT(” “,99)),MAX(1,FIND(”#",SUBSTITUTE({Transaction Name}," “,REPT(” ",99)))-50),99))

This could be greatly simplified by using regular expressions and the REGEX_EXTRACT() function:

IF({Transaction Name}, REGEX_EXTRACT({Transaction Name}, "#[^\\s]+"))

Screen Shot 2021-09-03 at 11.07.07 PM

That extracts everything beginning with the # symbol up to—but not including—the next whitespace in the string. I wrapped the IF() function around it to prevent an #ERROR result if {Transaction Name} is empty.

Note to self: disable out-of-office autoresponder for Airtable community forum updates. :rofl:

Thank you Justin, this works perfectly. My apologies about the autoresponder.