string_matcher v0.1.0 StringMatcher
Documentation for StringMatcher.
Link to this section Summary
Functions
Add a regexp to the list if its the correct format.
Match a string to a regexp.
Match a string to a regexp.
Create a new list for strings
Link to this section Functions
Link to this function
add_regexp(list, regexp, result)
Add a regexp to the list if its the correct format.
Returns a list of regular expressions.
Examples
iex> StringMatcher.add_regexp([], ~r/S(?
Link to this function
match(list, string)
Match a string to a regexp.
Returns the values that are passed as the second argument.
Examples
iex> StringMatcher.add_regexp([], ~r/S(?<season_num>+)E(?<episode_num>+)/i, %{}) |> StringMatcher.match("Prison Break E01")
{:error, "no match"}
iex> StringMatcher.add_regexp([], ~r/S(?<season_num>+)E(?<episode_num>+)/i, %{}) |> StringMatcher.match_captures("Prison Break S01E01")
{:ok, %{"episode_num" => "01", "season_num" => "01"}}
iex> StringMatcher.add_regexp([], ~r/S(?<season_num>+)E(?<episode_num>+)/i, %{"name" => "Fargo"}) |> StringMatcher.match("Prison Break S01E01")
{:ok, %{"name" => "Fargo"}}
Link to this function
match_captures(list, string)
Match a string to a regexp.
Returns either the values passed as the second argument otherwise it returns the captures.
Examples
iex> StringMatcher.add_regexp([], ~r/S(?<season_num>+)E(?<episode_num>+)/i, %{}) |> StringMatcher.match_captures("Prison Break S01E01")
{:ok, %{"episode_num" => "01", "season_num" => "01"}}
iex> StringMatcher.add_regexp([], ~r/S(?<season_num>+)E(?<episode_num>+)/i, %{"name" => "Fargo"}) |> StringMatcher.match_captures("Prison Break S01E01")
{:ok, %{"name" => "Fargo"}}
Link to this function
new()
Create a new list for strings
Returns []
Examples
iex> StringMatcher.new()
[]