I've got a weird question about Google Sheets.
First, here's what I've got so far, but it returns an error "Function REGEXEXTRACT parameter 2 value "My Text here" is not a valid regular expression."
=IF(REGEXEXTRACT(W8, $Y$1), SUBSTITUTE(W8,$Y$1, ""),
IF(REGEXEXTRACT(W8, $Y$2), SUBSTITUTE(W8,$Y$2, ""),
IF(REGEXEXTRACT(W8, $Y$3), SUBSTITUTE(W8,$Y$3, ""),
IF(REGEXEXTRACT(W8, $Y$4), SUBSTITUTE(W8,$Y$4, ""), ""
)
)
)
)
Basically, what I want it to do, is check if a cell contains certain text, with different results based on what text it finds. I have 4 possibilities of what it could find, let's say it Looks for Abc, def, ghi, jkl in a line of text. When it sees abc, it looks at W8, and substitutes the matching text in W8 with $Y$1. If it sees def, it looks at W8, and substitutes the matching text in W8 with $Y$2. Etc. Etc. Etc. And then Ideally it shows as blank if it doesn't find any of those.
I feel like i'm really close to getting it right, but I just can't see it.
Edit
I've added the istext function to it, and it removes the error message, but now it's just returning a blank
=IF(ISTEXT(regexextract(W8, $Y$1)), SUBSTITUTE(W8,$Y$1, ""),
IF(ISTEXT(regexextract(W8, $Y$2)), SUBSTITUTE(W8,$Y$2, ""),
IF(ISTEXT(regexextract(W8, $Y$3)), SUBSTITUTE(W8,$Y$3, ""),
IF(ISTEXT(regexextract(W8, $Y$4)), SUBSTITUTE(W8,$Y$4, ""), ""
)
)
)
Edit 2
For clarity's sake, I'm including what each of the cells I'm editing are:
W8: Value: =SUBSTITUTE(C8,V8, "")
Text: /slideshows/blah-blah.html?utm_source=naytev&utm_campaign=ab&utm_medium=cwpg&utm_term=paid
$Y$2: ?utm_source=naytev&utm_campaign=ab&utm_medium=cwpg&utm_term=paid
EDIT 3
I've condensed my problem down to one line, to further simplify the problem: =IF(ISTEXT(REGEXMATCH(W8, $Y$2)), SUBSTITUTE(W8,$Y$2, ""), "00")
Returns 00