# How to fix the REGEXEXTRACT "expects text values" error in Google Sheets

REGEXEXTRACT, REGEXMATCH and REGEXREPLACE only accept text. Convert numbers first: =REGEXEXTRACT(TO_TEXT(A2),"^\d{3}").

**Google Sheets:** `=REGEXEXTRACT(TO_TEXT(A2),"^\d{3}")`

**Excel:** Excel 365's REGEXEXTRACT converts numbers to text by itself, so =REGEXEXTRACT(A2,"^\d{3}") works as is. =LEFT(A2,3) also works in both apps.

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Phone (number) | Area code |
| 6125550142 |  |
| 6515550187 |  |
| 7635550021 |  |
| 9525550199 |  |
| 2185550110 |  |

Formula in B2, filled to B6: `=REGEXEXTRACT(TO_TEXT(A2),"^\d{3}")`

Result: 612; 651; 763; 952; 218

## How it works

Google Sheets' regex functions refuse numbers: `=REGEXEXTRACT(A2,"^\d{3}")` on 6125550142 gives "Function REGEXEXTRACT parameter 1 expects text values". TO_TEXT converts the number to the text you see in the cell, and the pattern `^\d{3}` then takes the first three digits.

## Other ways

- `=REGEXEXTRACT(A2&"","^\d{3}")`: Joining an empty text also converts the number. Unlike TO_TEXT, it ignores the cell's number format.

## Common mistakes

- TO_TEXT uses the displayed format: a number shown as 6,125,550,142 becomes text with commas. Use `A2&""` when the format gets in the way.
- Dates are numbers too. Convert them with `TEXT(A2,"yyyy-mm-dd")` to control the result.

## Questions

**Does REGEXMATCH have the same problem?**

Yes. Use `=REGEXMATCH(TO_TEXT(A2),"^612")`.

**How do I get a number back out?**

Wrap the result in VALUE: `=VALUE(REGEXEXTRACT(TO_TEXT(A2),"^\d{3}"))`.

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/fix-regexextract-expects-text-values-error
