# Why does REGEXMATCH not work on numbers in Google Sheets

REGEXMATCH only accepts text and returns #VALUE! for a number. Convert it first: `=REGEXMATCH(TO_TEXT(A2),"^2026")`.

**Google Sheets:** `=REGEXMATCH(TO_TEXT(A2),"^2026")`

**Excel:** Excel's text functions accept numbers directly, so no conversion is needed: `=LEFT(A2,4)="2026"`, or `=REGEXTEST(A2,"^2026")` in Microsoft 365.

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Order ID | Placed in 2026? |
| 20260412 |  |
| 20251130 |  |
| 20260105 |  |
| 20251218 |  |
| 20260220 |  |
| 20260318 |  |

Formula in B2, filled to B7: `=REGEXMATCH(TO_TEXT(A2),"^2026")`

Result: TRUE; FALSE; TRUE; FALSE; TRUE; TRUE

## How it works

The REGEX functions in Google Sheets work on text only; give them a number and they stop with "Function REGEXMATCH parameter 1 expects text values". TO_TEXT turns 20260412 into the text "20260412", and `^2026` then checks the start of it.

## Other ways

- `=REGEXMATCH(A2&"","^2026")`: Joining an empty string also turns the number into text.
- `=LEFT(A2,4)="2026"`: For a fixed prefix, LEFT is enough and works in Excel too.

## Common mistakes

- TO_TEXT uses the cell's format: a number shown as 20,260,412 becomes "20,260,412". Format ID columns as plain numbers or plain text.
- Converting can't restore leading zeros that were never stored. Type IDs like 00742 into a column formatted as plain text.

## Questions

**Does REGEXEXTRACT have the same problem?**

Yes, all three REGEX functions need text. Use `REGEXEXTRACT(TO_TEXT(A2),"\d{4}")`.

**How do I check a whole column of numbers?**

Use ARRAYFORMULA: `=ARRAYFORMULA(REGEXMATCH(TO_TEXT(A2:A7),"^2026"))`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/regexmatch-error-on-numbers
