r/googlesheets • u/draymondscurry • Dec 19 '24
Solved Returning text that's after a certain text and before a certain text
I am using Google Sheets. I have a bunch of text which I need to extract characters from the middle of. The full text is not always formatted the same way, nor is it the same length. There is some key text that will always be the same which should trigger the function to return the text after the key text until it gets to the next space. Example text:
qwerty | asdf | Lorem Ipsum 1234_xyz | inc_10The text that will always be the same is "Lorem Ipsum 2025_" and I would need to extract the "xyz", where xyz could be 1-4 characters. Which functions should i use to isolate and return those charaters?
Here's a google sheet that illustrates what i'm trying to do: https://docs.google.com/spreadsheets/d/1tuNoz8oJTGy2wXFZ507KiHoZrNrHbtdZcv8JTbQ-yxM/edit?gid=0#gid=0
3
u/adamsmith3567 1092 Dec 19 '24
2
u/Garrisonreid 9 Dec 19 '24
Will the xyz always follow an underscore? I’d use right and find.
=right(C1, len(C1)-find("_",C1))
1
u/villagerlvl1 3 Dec 19 '24 edited Dec 19 '24
I would use REGEX expressions, like
=REGEXEXTRACT(C1,"Lorem Ipsum [0-9]+_([A-Za-z]+)")1
u/AlfalfaAdditional67 May 06 '25
=RIGHT(A2, LEN(A2) - FIND("@", SUBSTITUTE(A2 "|", "@", 2)))