Extract digits from string - Google spreadsheet

If some of source cells may contain only numbers it is safer to convert the value to text first, then regexreplace. Otherwise it produces error.

Result as text

=REGEXREPLACE(TO_TEXT(C1),"\D+", "")

Result as number

=VALUE(REGEXREPLACE(TO_TEXT(C1),"\D+", ""))

The same for whole column

=ARRAYFORMULA(IF(LEN(C1:C), VALUE(REGEXREPLACE(TO_TEXT(C1:C),"\D+", ""))))

enter image description here


These work with integers, decimals and negatives:

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

regex negative decimals - google sheets function


You may replace all non-digit characters using the \D+ regex and an empty string replacement with

=REGEXREPLACE(A11,"\D+", "")

or with casting it to a number:

=VALUE(REGEXREPLACE(A11,"\D+", ""))

enter image description here