How to extract numbers from string in Google Sheets?

To extract numbers from a string in Google Sheets, you can use the REGEXEXTRACT formula. This formula allows you to specify a regular expression (regex) which defines the pattern of the numbers you want to extract from the string. The formula will then return the first set of numbers from the string that match the regex pattern. You can also use the REGEXMATCH formula to return whether or not a string contains a certain pattern.


You can use the following formula to extract numbers from a string in Google Sheets:

=REGEXEXTRACT(A1,"-*d*.?d+")

This formula will extract integers, decimals, and negative signs from a string.

The following example shows how to use this formula in practice.

Example: Extract Numbers from String in Google Sheets

Suppose we have the following list of strings in Google Sheets:

We can use the following formula to extract numbers (including integers, decimals, and negative signs) from the strings:

=REGEXEXTRACT(A2,"-*d*.?d+")

The following screenshot shows how to use this formula in practice:

extract number from string in Google Sheets

Notice that the values in column B only contain the integers, decimals, and negative signs from the values in column A.

If you ever attempt to use this formula and you receive #VALUE! as a result, make sure that the strings are formatted as Plain text.

To convert the strings to Plain text, highlight the cell range that contains the strings, then click the Format tab along the top ribbon, then click Number and then click Plain text.

This should resolve any #VALUE! issues.

x