Extract digits from string - Google spreadsheet

前端 未结 6 1014
情深已故
情深已故 2021-02-01 17:19

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

6条回答
  •  余生分开走
    2021-02-01 18:04

    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+", ""))))
    

提交回复
热议问题