标签: elixir
如果给定此字符串'Cool1, let's g3et to work',如何返回该值Cool, let's get to work?用长生不老药?
'Cool1, let's g3et to work'
Cool, let's get to work
到目前为止,我一直在尝试使用Regex进行锁定。谢谢!
答案 0 :(得分:5)
使用String.replace:
String.replace
String.replace("Cool1, let's g3et to work", ~r/\d/, "")
\d表示任何数字(又称数字值)。
\d
答案 1 :(得分:1)
使用Regex.replace:
Regex.replace(~r/\d/, "Cool1, let's g3et to work", "")