Thursday, November 23, 2017

yogi_Using Regexmatch In Multiple Columns

Google Spreadsheet   Post  #2299

Yogi Anand, D.Eng, P.E.      ANAND Enterprises LLC -- Rochester Hills MI     Nov-23-2017
question by: HoraceGZZ
https://productforums.google.com/forum/?utm_medium=email&utm_source=ba_notification#!topic/docs/iZJt1rnee1g;context-place=forum/docs

Using ARRAYFORMULA and REGEXMATCH in 2 columns

Hello, what I'm trying to do is very simple. I need a single arrayformula (cell C1) that uses RegExMatch to verify if either column A or column B contain a specific text ("foo"). If any of the 2 cells on each row contain the specified text it will return a 1, otherwise it will return a 0. Preferably it should be a single formula at the top.

This would be the desired result:
ABC
1foocvb1
2ertfooer1
3sdfasd0
4qwefoo1
5foodrty1
6qwerxcv0


Edit: here's an editable version of the above example: 
https://docs.google.com/spreadsheets/d/1VUFjL2c2kWhC_rhGlJRTJ7qVlC4svHeHSTmFZT11XFk

I tried the following formula but it doesn't work:
=ARRAYFORMULA(IFERROR(IF(OR(REGEXMATCH(A1:A,"foo")=TRUE,REGEXMATCH(B1:B,"foo")=TRUE),1,0)))

The following formula works but the results take 2 columns (C and D) instead of just one:
=ARRAYFORMULA(IFERROR(IF(REGEXMATCH(A1:B,"foo")=TRUE,1,0))

The following formula works but I have to copy it down instead of being a single formula at the top:
=IFERROR(IF(OR(REGEXMATCH(A1,"foo")=TRUE,REGEXMATCH(B1,"foo")=TRUE),1,0))

Is this possible or do I have to use the copy down version?

Thanks in advance

No comments:

Post a Comment