Formula to extract numbers from a text string

前端 未结 3 1545
無奈伤痛
無奈伤痛 2020-12-22 03:40

How could I extract only the numbers from a text string in Excel or Google Sheets? For example:

A1 - a1b23eg67
A2 - 15dgrgr156

Result desir

3条回答
  •  情话喂你
    2020-12-22 04:14

    You can do it with capture groups in Google Sheets

    =REGEXREPLACE(A1,ʺ(\d)|.ʺ,ʺ$1ʺ)
    

    Anything which matches the contents of the brackets (a digit) will be copied to the output, anything else replaced by an empty string.

    Please see @Max Makhrov's answer to this question

    or

    =regexreplace(A1,ʺ[^\d]ʺ,ʺʺ)
    

    to remove anything which isn't a digit.

提交回复
热议问题