Extract digits from string - Google spreadsheet

thanos.a picture thanos.a · Jan 19, 2017 · Viewed 49k times · Source

In Google spreadsheets, I need a formula to extract all digits (0 to 9) contained into an arbitrary string, that might contain any possible character and put them into a single cell.

Examples (Input -> Output)

d32Ελληνικάfe9j.r/3-fF66 -> 329366
h01j2j3jFxF$$4j5j6j7j8j9 -> 0123456789

Answer

Wiktor Stribiżew picture Wiktor Stribiżew · Jan 19, 2017

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