Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Google Sheets Replace REGEXMATCH with REGEXEXTRACT

$
0
0

I am working with a Google Sheet where column A contains a set of values. Every value contains the following string "SAME_WORD LETTER", where LETTER is one of the alphabet letters, like "SAME_WORD A", "SAME_WORD B", "SAME_WORD C", etc. The first letter in SAME_WORD is always capital, the string may be preceded and followed by either a space or a symbol (like a dash) but never by another letter or number.

The following formula does what I need for A, B, and C but it's very long with all the alphabet letters

=ArrayFormula(IF(REGEXMATCH(A:A,"\b SAME_WORD A(.*)"),"SAME_WORD A",IF(REGEXMATCH(A:A,"\b SAME_WORD B(.*)"),"SAME_WORD B",IF(REGEXMATCH(A:A,"\b SAME_WORD C(.*)"),"SAME_WORD C"))))

I would like to improve efficiency and learn something so my request is to modify my formula to remove the conditionals and use something else instead, like REGEXEXTRACT.

TIA


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>