Home > Blockchain >  How to extract the exact match from the string by using REGEXEXTRACT in Google Sheet
How to extract the exact match from the string by using REGEXEXTRACT in Google Sheet

Time:08-17

I have one issue with REGEXEXTRACT in Google Sheet. I want to match and extract the exact word. If I use the below formula, it will display the result “Sing,” but I want it to display “NA.” Because the source cell i.e A1 cell does not have the “Sing” word but it has the word "Singapore". =regexextract(A1,”(?i)Sing”) So, how can we extract the exact match instead of the partial match? Thanks & Regards, Vineet

CodePudding user response:

REGEXEXTRACT is going to extract the part of the string that matches your regex expression. What you need to use is REGEXMATCH which returns a TRUE or FALSE and use it as a condition for IF:

=IF(REGEXMATCH(A1,(?i)Sing”), A1,"")

CodePudding user response:

use:

=IF(REGEXMATCH(A1; "\b(?i)sing\b"); A1; "NA")

enter image description here

(?i)    case insensitive
\b      boundary
  • Related