Google Sheets Extract Number from String: Step-by-Step Guide
Master practical, formula-based methods to extract numbers from strings in Google Sheets using REGEXEXTRACT, REGEXREPLACE, and VALUE. Includes patterns, examples, tips, and troubleshooting.

Learn how to extract numbers from a string in Google Sheets using built‑in functions like REGEXEXTRACT, REGEXREPLACE, and VALUE. This guide covers common patterns, edge cases, and practical templates you can copy-paste. No scripting required, and you’ll improve data reliability when numbers appear inside text fields. By the end you’ll have reusable formulas for quick wins.
Why extracting numbers from strings matters in Google Sheets
Extracting numbers from strings is a foundational data-cleaning task that helps you convert mixed data into actionable insights. When numbers sit inside text—such as product IDs like "ID-12345" or prices embedded in notes—simple text functions miss the numeric portion. The How To Sheets team emphasizes that mastering this skill reduces manual edits and enables reliable downstream analysis. This block will orient you to why this task matters, the typical patterns you’ll encounter, and how a strategic approach pays off in real-world sheets.
In many datasets, numbers are not isolated as separate cells; they are embedded in descriptions, codes, or messages. You’ll want formulas that extract a number while preserving the surrounding context for auditing. By building robust patterns, you can handle integers, decimals, signed numbers, and even numbers with thousands separators. This foundation is crucial for students, professionals, and small business owners who regularly tidy data in Google Sheets.
Recognizing number patterns in text
Before you write formulas, scan your data for patterns. Numbers can appear as simple integers (e.g., 42), decimals (e.g., 3.14), or signed values (e.g., -7). Some strings include thousands separators (e.g., 1,234), while others present numbers with currency symbols or units (e.g., "$1,000.50" or "temp: -12.5C"). The most reliable extraction uses regular expressions (regex) to locate a numeric pattern, then converts it to a numeric value with VALUE. If your data uses locale-specific decimal separators, adjust patterns accordingly. For best results, test several sample strings to confirm your regex captures only the intended numbers.
Tip: Build a small test sheet with diverse examples to validate patterns before applying them to large datasets. This practice reduces errors and ensures consistency across rows.
Core formulas: REGEXEXTRACT, REGEXREPLACE, VALUE
Google Sheets exposes three core functions for numeric extraction from strings:
- REGEXEXTRACT(text, regular_expression): grabs the first match of a regex pattern.
- REGEXREPLACE(text, regular_expression, replacement): removes unwanted characters from a string.
- VALUE(text): converts a text string that represents a number into a numeric value.
A typical workflow is: use REGEXEXTRACT to locate the number, optionally clean it with REGEXREPLACE (e.g., removing commas), then wrap with VALUE to produce a true number. When numbers aren’t present, wrap formulas with IFERROR to return a blank or zero instead of an error. This trio is the backbone of robust extraction in Google Sheets.
Simple integers extraction: formula templates
If you only need integers, a reliable starting pattern is -?\d+. The corresponding formula converts the match into a number:
=IFERROR(VALUE(REGEXEXTRACT(A2, "-?\\d+")), "")
This formula looks for an optional minus sign followed by digits, extracts that portion, converts it to a number, and returns an empty string if nothing is found. Replace A2 with your target cell. For multiple cells, drag down or use ARRAYFORMULA for bulk processing. This approach is a solid baseline for integer extraction in many datasets.
Decimals and signed numbers: extracting decimals
To capture decimals and signed values, extend the pattern to include an optional decimal part:
=IFERROR(VALUE(REGEXEXTRACT(A2, "-?\\d+(?:\\.\\d+)?")), "")
The (?:\.\d+)? portion matches a decimal point followed by digits, if present. This template handles numbers like -12, 3.14, and 0.5. If you also need to extract numbers with thousands separators, see the next section for locale-aware patterns and cleanup steps.
Handling thousands separators and locale differences
Numbers may use commas as thousands separators (e.g., 1,234.56). To safely convert such strings, first extract the number including commas, then remove commas before converting:
=IFERROR(VALUE(REGEXREPLACE(REGEXEXTRACT(A2, "-?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?"), ",", "")), "")
This pattern matches either a plain number or one with comma separators, strips commas, and then converts the result. If your locale uses a comma as the decimal separator, switch to a dot as the decimal and adjust accordingly. Always test with representative data to avoid locale pitfalls.
Mixed content: extracting numbers within longer strings
When numbers are embedded in phrases (e.g., "order123" or "ref-56x"), anchored patterns work well. Use REGEXEXTRACT to pull numeric substrings regardless of surrounding text:
=IFERROR(VALUE(REGEXEXTRACT(A2, "-?\\d+(?:\\.\\d+)?")), "")
If you have multiple numbers per string and need all occurrences, REGEXEXTRACT alone won’t suffice—you’d typically handle one per row or use SPLIT with clever delimiters, or use an array-based approach with REGEXREPLACE to isolate numbers step-by-step. This approach emphasizes correctness over cleverness; start simple and scale.
Testing formulas and debugging tips
Regex patterns can behave differently across datasets. Always:
- Keep a small sample set of representative strings.
- Use IFERROR to gracefully handle missing numbers and to identify problematic rows.
- Break complex formulas into helper columns to verify each stage (extraction, cleanup, conversion).
- Check locale settings if decimals and thousands separators differ from your default. If a test string fails, isolate the failing portion and adjust the regex accordingly.
A practical debugging strategy is to test REGEXEXTRACT first to confirm the numeric portion is captured, then wrap with VALUE and IFERROR in a separate step. This incremental approach saves time and reduces guesswork.
Real-world templates: copy-paste formulas for common scenarios
Here are ready-to-use formulas you can copy-paste directly into your sheet. Adjust cell references as needed.
- Integers only:
=IFERROR(VALUE(REGEXEXTRACT(A2, "-?\\d+")), "") - Decimals and integers:
=IFERROR(VALUE(REGEXEXTRACT(A2, "-?\\d+(?:\\.\\d+)?")), "") - Numbers with thousands separators:
=IFERROR(VALUE(REGEXREPLACE(REGEXEXTRACT(A2, "-?(?:\\d{1,3}(?:,\\d{3})+|\\d+)(?:\\.\\d+)?"), ",", "")), "")
If your data includes multiple numbers per cell and you need all occurrences, consider splitting on non-numeric boundaries and aggregating results as needed, or using Apps Script for advanced parsing. The goal is to produce a clean numeric value you can use in calculations and summaries.
Common pitfalls and how to avoid them
Be mindful of edge cases that break naive extractions:
- Strings with no numbers should not produce an error in your sheet; handle with IFERROR.
- Negative numbers or decimals may require explicit patterns to prevent partial matches.
- Locale differences can invert decimal separators and thousands separators, so test across your data range.
- Regex greediness can pull more digits than intended; anchor patterns or test with diverse samples.
By validating formulas on representative data and using clear error handling, you’ll minimize rework and ensure robust extractions across your Google Sheets projects.
Tools & Materials
- Google Sheets (web or app)(Open a sheet where you will test the extraction formulas)
- Sample data column (strings with embedded numbers)(Include integers, decimals, negatives, and numbers with separators)
- Regex tester or test data set (optional)(Helps validate patterns before applying to the full sheet)
- Locale awareness notes (optional)(Check decimal/thousand separators for your region)
- Calculator or quick verifier (optional)(Cross-check extracted numbers with a trusted method)
Steps
Estimated time: 25-40 minutes
- 1
Identify target data column
Locate the column that contains strings with embedded numbers. Note the variety of patterns so you can pick appropriate regex patterns. This step ensures you apply formulas to the correct data range.
Tip: Label the column (e.g., DataWithStrings) to keep formulas readable. - 2
Choose the numeric pattern to extract
Decide whether you need integers, decimals, signed numbers, or numbers with thousands separators. This choice guides your regex and ensures accuracy.
Tip: Start with a simple integer pattern (-?\d+) and expand as needed. - 3
Apply REGEXEXTRACT to locate the number
Insert REGEXEXTRACT in a helper column to pull the numeric substring from each string. Verify a handful of sample rows show the expected digits.
Tip: Test with strings that include no numbers to verify error handling. - 4
Convert the extracted text to a number
Wrap the extraction with VALUE to get a numeric value suitable for calculations. Use IFERROR to gracefully handle missing numbers.
Tip: Avoid nesting too many functions in one cell; use helper columns first. - 5
Handle thousands separators and locale specifics
If your data uses commas for thousands, remove them before VALUE. Adjust patterns if your locale uses different decimal separators.
Tip: Use REGEXREPLACE to strip commas before VALUE when needed. - 6
Validate across a sample of rows
Compare a handful of outputs with a manual check to ensure accuracy. Adjust the regex if unexpected digits appear.
Tip: Create a side-by-side comparison column for quick visual checks. - 7
Scale to multiple rows with ARRAYFORMULA
If you want to apply the extraction across many rows without dragging, wrap the formula with ARRAYFORMULA and apply to the entire range.
Tip: Be mindful of performance on very large sheets.
FAQ
What is the best function to extract numbers from a string in Google Sheets?
REGEXEXTRACT is the most reliable starting point for pulling a numeric substring. Wrap with VALUE to convert the text to a number, and use IFERROR to handle missing results.
REGEXEXTRACT is the best starting point for pulling a number from a string. Wrap it with VALUE to convert to a number and use IFERROR to handle cases where no number exists.
How do I extract decimal numbers from text in Google Sheets?
Use a decimal-allowing pattern like -?\d+(?:\.\d+)?. Then apply VALUE to convert to a numeric value. Example: =IFERROR(VALUE(REGEXEXTRACT(A2, "-?\\d+(?:\\.\\d+)?")), "").
Use a decimal-friendly pattern like -?\d+(?:\.\d+)? and wrap with VALUE to convert to a number.
Can REGEXEXTRACT pull multiple numbers from a string?
REGEXEXTRACT returns only the first match. For multiple numbers, you’ll need a combination of functions or Apps Script, or process one number per row.
REGEXEXTRACT grabs the first number; for more, use other methods or scripts.
Why do I get errors when extracting numbers?
If there’s no number in the string or the string doesn’t match the pattern, REGEXEXTRACT returns an error. Use IFERROR to return a blank or a default value.
If there's no number, you get an error. Use IFERROR to handle it gracefully.
What about numbers with thousands separators?
Extract the number including the commas, then remove commas before converting: VALUE(REGEXREPLACE(REGEXEXTRACT(...), ",", ""))
Handle commas by removing them before converting to a number.
What should I do if my data uses a different decimal separator?
Adapt the pattern to your locale (e.g., use a comma for decimals or adjust the REGEX accordingly) and test with sample data.
Adapt the regex to your locale’s decimal separator and test with samples.
Is there a quick template for common use cases?
Yes. You can copy a ready-to-use integer or decimal template and then modify the cell reference to suit your sheet. Start simple and expand as needed.
Use a ready template and adjust references as needed.
Watch Video
The Essentials
- Identify the exact numeric pattern needed before building formulas.
- Use REGEXEXTRACT + VALUE for reliable numeric extraction.
- Handle errors and locale differences to maintain data integrity.
- Test formulas on representative samples prior to large-scale use.
