I’m working with a Google Sheets document that contains financial data. In column D, I have transaction descriptions, and I need to pull out up to three words or numbers from column E that appear right after the word “finish”.
I tried using a lookbehind pattern but Google Sheets uses RE2 engine which doesn’t support this feature. When I attempt this formula:
=REGEXEXTRACT(D1,"(?<=finish\s)(\w+)")
It gives me an error message. Since regex lookbehind won’t work here, what other approaches can I use in Google Sheets to get the text that comes after my target word? I’m open to using different functions or maybe a combination of text manipulation functions to achieve this result.
Had this exact problem a few months ago with invoice descriptions. Skip the regex headache - use FIND and MID functions instead. Find where “finish” appears in your text, add 7 (for "finish " plus the space), then use MID to grab everything after that point. Try: =MID(D1,FIND("finish ",D1)+7,50). The 50 gives you enough characters for multiple words. You’ll probably need to trim extra spaces, but it’s way more reliable than fighting RE2’s quirks.
Try this workaround - use REGEXEXTRACT to capture the whole pattern including “finish”. Something like =REGEXEXTRACT(D1,"finish\s+(\w+\s*\w*\s*\w*)") grabs “finish” plus your 3 words after it. Then use SUBSTITUTE to strip out the "finish " part. It’s messy but completely avoids the lookbehind issue.
You could also use the SPLIT function - it’s cleaner than manual string manipulation. Try =SPLIT(D1,"finish ") then grab the second element with INDEX. The formula becomes =TRIM(INDEX(SPLIT(D1,"finish "),2)). This splits your text at "finish " and gives you everything after it. TRIM cleans up any extra whitespace. I use this all the time for parsing payment descriptions when I need text after specific keywords. Works way better than regex in Google Sheets since you don’t hit those annoying RE2 limitations. Just double-check that your target word’s spelled the same across all rows.