Raman Singh
Raman Singh

Reputation: 79

How to extract a specific words/text from a cell into another cell

If in a cell there are few texts like, Hi, How are you, Hello. I want to show in another cell if that cell contains either Hi and/or Hello and display the exact text on another cell.

enter image description here

I'm using Google Sheets.

I'm a beginner and searched a lot about my question but didn't find any.

Upvotes: 0

Views: 732

Answers (2)

player0
player0

Reputation: 1

try:

=INDEX(BYROW(IFNA(REGEXEXTRACT(SPLIT(A2:A5, ", "), "(?i)hello|hi")), 
 LAMBDA(x, TEXTJOIN(", ", 1, x))))

enter image description here

Upvotes: 1

pgSystemTester
pgSystemTester

Reputation: 9932

Use search if you don't care about case sensitivity:

=TEXTJOIN(",",true,
 if(isnumber(search("hi",a2)),"hi",""), 
  if(isnumber(search("hello",a2)),"hello",""))

If case-sensative then:

=TEXTJOIN(",",true,
 if(isnumber(find("hi",A2)),"hi",""), 
  if(isnumber(FIND("hello",A2)),"hello",""))

enter image description here

Upvotes: 1

Related Questions