I know there is string:strip in erlang. But its behaviour is strange for me.
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
And I need a function to delete all leading/trailing blank chars, including whitespace, \t, \n, \r etc.
some_module:better_strip(A) % => []
Does erlang have one function can do this? Or if I have to do this myself, what is the best way?
Try this:
re:replace(A, "(^\\s+)|(\\s+$)", "", [global,{return,list}]).