我知道 erlang 中有 string:strip 。但它的行为对我来说很奇怪。
A = " \t\n" % two whitespaces, one tab and one newline
string:strip(A) % => "\t\n"
string:strip(A,both,$\n) % string:strip/3 can only strip one kind of character
我需要一个函数来删除所有前导/尾随空白字符,包括空格、\t、\n、\r 等。
some_module:better_strip(A) % => []
erlang 有一个函数可以做到这一点吗?或者如果我必须自己做这件事,最好的方法是什么?
最佳答案
现在使用 string:trim
1> string:trim(" \t\n").
[]
关于string - 如何在 Erlang 中去除字符串中的所有空白字符?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12794358/