We’re improving Formula Genius. We’re redesigning the app and fixing issues along the way. Sorry for any disruption, and thank you for your patience.
Google Sheets intermediate

How to Extract Digits from Mixed Text in Google Sheets?

Struggling to isolate numbers from a text string? Use REGEXEXTRACT to effortlessly pull out all digits from your data.

Formula Genius can generate a draft from a plain-English prompt. Supported formulas can be checked with sample cases; review the coverage on the result.

The formula

Prompt

"Extract all digits from a cell that contains mixed text and numbers using REGEXEXTRACT"

Google Sheets
=REGEXEXTRACT(A1, "[0-9]+")

This formula extracts the first sequence of digits found in a text string.

Step-by-step breakdown

  1. Identify the cell containing mixed text and numbers (e.g., A1).
  2. Use the REGEXEXTRACT function to apply a regular expression.
  3. The regular expression '[0-9]+' matches one or more digits.
  4. The function returns the first match of the specified pattern.

Edge cases & warnings

  • The cell contains no digits, resulting in an error.
  • The cell contains multiple sequences of digits, only the first is returned.
  • The cell is empty, leading to an error.
  • The digits are formatted with spaces or other characters, which may affect extraction.

Examples

Prompt

"Order number: 12345ABC"

Google Sheets
12345
Prompt

"Total cost is $99.99"

Google Sheets
99

Frequently asked questions

Can REGEXEXTRACT return multiple matches?

No, it only returns the first match found.

What if my text has no digits?

The formula will return an error if no digits are found.

How can I extract all digits, not just the first?

Use ARRAYFORMULA combined with REGEXREPLACE for multiple matches.

Can't find what you need?

Describe a formula in plain English. Formula Genius drafts and explains it, and can check supported formulas on sample cases.