Extract strings segments in elixir
16 July, 2021 - 1 min read
Sometimes we want extract string segments with a simple match how do this using elixir ?
How it Works ?
The pattern match operator strutcture to do this is basically that
"string to match" <> variable_to_receive = "string to match segment"
"ContentType: " <> my_variable = "ContentType: Text/Html" IO.puts(my_variable) // outputs-> "Text/Html"
This is very useful when we need extract path segments from file path or any string.
$ exit code 0