When comparing two strings in Google Sheets, using =A1=B1 only works if the strings match exactly—including the word order. But what if the words are the same, just arranged differently?
For example, you might want to match "blue red green" with "red green blue" and return TRUE.
In this tutorial, you’ll learn how to compare two strings to check if they contain the same words, regardless of their order. You’ll also learn how to optionally ignore filler words like "the", "and", or "vs" if needed.
Let’s explore two useful methods—one that considers all words, and another that skips filler words and punctuation during comparison.
Example 1: Compare Two Strings Regardless of Word Order (All Words Considered)
This method checks if two strings contain the exact same words—no more, no less—regardless of their positions.
Sample Data
| A | B | Match? |
| cat dog mouse | mouse cat dog | TRUE |
| blue green red | red green blue | TRUE |
| pen pencil | pencil pen box | FALSE |
We’re comparing each string in column A with the corresponding string in column B.
Formula
=JOIN(" ", SORT(TOCOL(SPLIT(A1, " ")))) = JOIN(" ", SORT(TOCOL(SPLIT(B1, " "))))
Place this in cell C1 and drag it down.
Formula Breakdown
SPLIT(A1, " "): Splits the string into individual words.TOCOL(...): Converts the output to a single column for proper sorting.SORT(...): Sorts the list of words alphabetically.JOIN(" ", ...): Rejoins the sorted words into a single normalized string.- The same steps are applied to cell
B1, and the=operator checks for equality between the two processed strings.
Example 2: Compare Two Strings While Ignoring Filler Words
This method is useful when you want to compare strings by meaning—ignoring common filler words and punctuation.
Sample Data
| A | B | Match? |
| The quick brown fox | quick fox brown | TRUE |
| A pencil and a pen | pen pencil | TRUE |
| Box of chocolates | chocolates box | TRUE |
| Brazil Vs Germany | Germany Vs Brazil | TRUE |
You may need to tune the filler word list based on your use case.
Formula
=JOIN(" ", SORT(TOCOL(SPLIT(
TRIM(REGEXREPLACE(
REGEXREPLACE(LOWER(A1), "\b(a|an|and|are|as|at|be|but|by|for|from|has|have|if|in|into|is|it|its|of|on|or|that|the|to|was|were|with|vs|vs\.|v/s)\b[.,!?;:]*", ""),
"[^\w\s]", "")
), " "))))
=
JOIN(" ", SORT(TOCOL(SPLIT(
TRIM(REGEXREPLACE(
REGEXREPLACE(LOWER(B1), "\b(a|an|and|are|as|at|be|but|by|for|from|has|have|if|in|into|is|it|its|of|on|or|that|the|to|was|were|with|vs|vs\.|v/s)\b[.,!?;:]*", ""),
"[^\w\s]", "")
), " "))))
Place this in cell C1 and drag it down.
Formula Breakdown
LOWER(A1): Converts text to lowercase for uniform comparison.REGEXREPLACE(..., "\b(...)\b[.,!?;:]*", ""): Removes filler words and attached punctuation.REGEXREPLACE(..., "[^\w\s]", ""): Removes any remaining special characters.TRIM(...): Cleans up leading/trailing spaces.SPLIT(...),TOCOL(...),SORT(...),JOIN(...): Same as the first example.- The processed strings from A1 and B1 are finally compared using
=.
Tip: You can customize the filler word list in \b(...)\b to suit your context.
Summary
| Use Case | Ignores Filler Words? | Matches Order? | Allows Extra Words? |
| Compare word sets exactly | ❌ No | ❌ No | ❌ No |
| Compare by meaning (ignoring fillers) | ✅ Yes | ❌ No | ❌ No |
Related Tutorials
- Formula to Extract Listed Keywords from Titles in Google Sheets
- Get Most Frequent Keywords from Titles in Google Sheets
- Filter Out Matching Keywords in Google Sheets – Partial or Full Match
- How to Compare Two Columns for Matching Values in Google Sheets
- Compare Two Rows and Find Matches in Google Sheets
- Compare Comma-Separated Values in Google Sheets
- Compare All Columns with Each Other for Duplicates in Google Sheets





















