View Source ExAequoBase.Text (ExAequoBase v0.1.1)
Text based tools
Summary
Functions
Parses an input string up to a given string, returnig prefix and suffix
Types
@type atoms() :: [atom()]
@type binaries() :: [binary()]
@type error_t() :: {:error, binary()}
@type error_t(t) :: {:error, t}
@type maybe(t) :: nil | t
@type natural() :: non_neg_integer()
@type numbered(t) :: {t, number()}
@type numbered_lines_t() :: [numbered_line_t()]
@type ok_t() :: {:ok, any()}
@type ok_t(t) :: {:ok, t}
Functions
Parses an input string up to a given string, returnig prefix and suffix
iex(1)> parse_up_to("hello world", " ")
{"hello", "world"}
We can also use regular expressions
iex(2)> parse_up_to("hello world", ~r/\s+/)
{"hello", "world"}
We can decide to keep the string we parse up to
iex(3)> parse_up_to("hello world", ~r/\s+/, :keep)
{"hello", " world"}
Or to include it into the macth
iex(4)> parse_up_to("hello world", ~r/\s+/, :include)
{"hello ", "world"}