Munch
March 21, 2024, 8:16pm
1
I have a column of data that has been imported, A2:A1000. Along the way, it has been concatenated from two columns, using “AND”, “OR” or “WITH”. I only need the front half of this information. I also need it to be an exact case match, because sometimes the data in A:A could be “AmpersandWITHRedPyramid”, and a non-case match would return “Ampers”.
I’m thinking, put the terms I want to search/replace somewhere, like Column Z (Z1:Z3). But then I have no clue.
kenoMD
March 21, 2024, 10:12pm
2
Try this
=ArrayFormula(REGEXREPLACE(A2:A1000,“((AND|OR|WITH)\w+)”,“”))
pjd
March 21, 2024, 10:44pm
3
This might work :-
=ifs(iferror(find(“AND”,A2),0),index(split(A2,“AND”,FALSE),0,1),iferror(find(“OR”,A2),0),index(split(A2,“OR”,FALSE),0,1),iferror(find(“WITH”,A2),0),index(split(A2,“WITH”,FALSE),0,1))
Put that in B2 and copy it to B3-B1000
Munch
March 22, 2024, 2:25am
4
I’d really prefer to not use the AND/OR/WITH in the formula - as the list is actually about 30 words long.
You can construct the regex string with something like:
=CONCATENATE("((", TEXTJOIN("|", FALSE, Z1:Z30), ")\w+)")
Munch
March 22, 2024, 11:48am
6
This isn’t working - it’s spits out the same text.
kenoMD
March 22, 2024, 12:17pm
7
this is working for me
=ArrayFormula(REGEXREPLACE(A2:A100,“(AND|OR|WITH\w+)”,“”))
Munch
March 22, 2024, 1:05pm
8
Perfect! Now I’ll try to figure out the TEXTJOIN, and then I’ll add a SPLIT.
Munch
March 22, 2024, 1:17pm
9
Sorry - it’s actually only working on the first delimiter.
Munch
March 22, 2024, 1:56pm
10
I got it! The “w” was throwing things off.
ARRAYFORMULA(REEXREPLACE(A:A, TEXTJOIN(“|”, false, $Z$1:$Z$30, “+”), “$”). Then I’ll do a LEFT(B:B, FIND(“$”, B:B)-1).
kenoMD
March 22, 2024, 5:23pm
11
Guess I don’t understand your question, thought you wanted to keep everything before the AND|OR|WITH .
Oh well, if you got it to work Good!