I am aware of String.strip/2
, but I cannot figure out its usage for removing whitespaces.
String.strip "_some_", ?_ #=> "some"
If the string had whitespaces instead of _, how does one strip them? Also, it would be great if someone can explain what ? means here.
字符前面的问号返回其代码点,它在入门指南的这一部分中提到: http : //elixir-lang.org/getting-started/binaries-strings-and-char-lists.html
There's String.strip/1
which strips all unicode whitespace. So you can just
iex(2)> String.strip("\t\ntest ")
"test"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.