↓ソース
str = "Now I need a drink," IO.puts "ex. " <> str IO.puts "trim なし" words = String.split(str,[","," "]) # 空文字は除かない Enum.each( words, fn x -> IO.puts x end ) IO.puts "trim: true" words = String.split(str,[","," "], trim: true) # 空文字は除く Enum.each( words, fn x -> IO.puts x end )↓実行結果
Active code page: 65001 PS C:\Users\tomohiko\Documents\19_elixir> elixir .\split_test.exs ex. Now I need a drink, trim なし Now I need a drink # 空文字が出力される=空文字は除かれていない trim: true Now I need a drink
0 件のコメント:
コメントを投稿