我正在使用slu for elixir,我的想法是:我有一个字符串,[a-zA-Z0-9]用连字符分隔.喜欢:
string = "another-long-string-to-be-truncated-and-much-text-here"
Run Code Online (Sandbox Code Playgroud)
我想确保最大字符串长度等于30,但我也希望确保在达到最大长度时单词不会减半.所以前30个符号string是,another-long-string-to-be-trun但我希望有完全删除的another-long-string-to-be单词truncated.我怎样才能做到这一点?
elixir ×1