iex(1)> Regex.split ~r{([aeiou])}, "caterpillar"
["c", "t", "rp", "ll", "r"]
iex(2)> Regex.split ~r{([aeiou])}, "caterpillar", on: [:all]
["caterpillar"]
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-talk/3xQ4q5YSCnk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-ta...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Regex.scan(~r{(?!<[^aeiou])([aeiou]*)([^aeiou]*)}, "caterpillar") |>
Enum.map(&tl/1) |>
List.flatten |>
Enum.filter(fn s -> String.length(s) > 0 end)
["c", "a", "t", "e", "rp", "i", "ll", "a", "r"]
Regex.scan(~r{(?!<[^aeiou])([aeiou]*)([^aeiou]*)}, "caterpillar") |>Enum.map(&tl/1) |>List.flatten |>
Enum.filter(&String.last/1)
I can't seem to find a straightforward way of doing it either, but here is a relatively simple way of achieving the goal.
Regex.split ~r/()[aeiou]()/, "caterpillar", on: [1,2]
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-talk/3xQ4q5YSCnk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-ta...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To more generally split on all the parenthesized spots in the regex, no matter how many there are, but not around the whole thing.Regex.split ~r/()[aeiou]()/, "caterpillar", on: :all_but_first
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-talk/3xQ4q5YSCnk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-talk+unsubscribe@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "elixir-lang-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-ta...@googlegroups.com.
To unsubscribe from this group and all its topics, send an email to elixir-lang-ta...@googlegroups.com.
--
You received this message because you are subscribed to a topic in the Google Groups "elixir-lang-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elixir-lang-talk/3xQ4q5YSCnk/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elixir-lang-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.