名字后面有整数怎么去掉? (google sheet)
How to remove the integer behind the name if there is any? (google sheet)
大家好,
我的目标是删除名称后面的整数(如果存在),如上面的屏幕截图所示。除了手动操作之外,还有什么技巧可以做到这一点吗?这对我来说很有挑战性,因为名单不一致,因为有些名字后面没有整数。任何帮助将不胜感激!
在您的情况下,以下示例公式如何?
示例公式:
=ARRAYFORMULA(REGEXREPLACE(A3:A,"\d+$",""))
结果:
注:
- 如果要使用
TRIM
作为值,=ARRAYFORMULA(TRIM(REGEXREPLACE(A3:A,"\d+$","")))
怎么样?
参考:
已添加:
来自OP的后续回复,
Hi Tanaike, thanks for your input. I tested both formula. It works most of the time with the exception of Derrick Tan 1
. Beside that, is it possible to remove the -
as well if exist? I edited my question with new screenshot example, thank you.
在这种情况下,下面的示例公式如何?
示例公式:
=ARRAYFORMULA(TRIM(REGEXREPLACE(A3:A,"[-\s\d]+$","")))
结果:
大家好,
我的目标是删除名称后面的整数(如果存在),如上面的屏幕截图所示。除了手动操作之外,还有什么技巧可以做到这一点吗?这对我来说很有挑战性,因为名单不一致,因为有些名字后面没有整数。任何帮助将不胜感激!
在您的情况下,以下示例公式如何?
示例公式:
=ARRAYFORMULA(REGEXREPLACE(A3:A,"\d+$",""))
结果:
注:
- 如果要使用
TRIM
作为值,=ARRAYFORMULA(TRIM(REGEXREPLACE(A3:A,"\d+$","")))
怎么样?
参考:
已添加:
来自OP的后续回复,
Hi Tanaike, thanks for your input. I tested both formula. It works most of the time with the exception of
Derrick Tan 1
. Beside that, is it possible to remove the-
as well if exist? I edited my question with new screenshot example, thank you.
在这种情况下,下面的示例公式如何?
示例公式:
=ARRAYFORMULA(TRIM(REGEXREPLACE(A3:A,"[-\s\d]+$","")))