I have a column that contains a number of different regular expressions, like this:
| Regex Patterns |
| — |
| ^abc |
| ^def |
| ^ghi |
| … |
| ^xyz |
I have another column with some strings:
| Strings |
| — |
| abc123 |
| def456 |
I want a third column that indicates the row number of the regex pattern that matches each string. So, for the example above, I want C1 to end up containing “1” (since “abc123” matches “^abc”) and C2 to end up containing “2” (since “def456” matches “^def”).
**Example Result:**
| Regex Patterns | Strings | Matching Row |
| — | — | — |
| ^abc | abc123 | 1 |
| ^def | def456 | 2 |
I tried using `REGEXMATCH`, but it seems to only look at a single regex cell, not a range. How can I achieve this in Google Sheets?
Thanks in advance!
user3434049 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.