Wildcard v0.2.0 Wildcard View Source
Provides functions for dealing with wildcard expressions which are intended to match agains strings.
A wildcard expression is a string that contains *
characters which indicate
that any text can be substituted at the location of the *
characters. An
example of a wildcard expression would be "ch*se"
, which would match
"cheese"
, but not "cats"
.
Options
The following options can be specified for the functions in the Wildcard module:
match_type
- determines what will be matched by a wildcard character. The default is:one_or_more
:one_or_more
- Matches one or more characters.:zero_or_more
- Matches any number of characters or none at all.:one
- Matches exactly one character.
Link to this section Summary
Functions
Converts an expression that can contain wildcards into a regex that can be used to match text
Link to this section Functions
Converts an expression that can contain wildcards into a regex that can be used to match text.
The resulting regex does not anchor to the beginning or end of the string using ^ or $. All non-wildcard text in the given expression is converted to raw text.
Examples
iex> Wildcard.to_regex("man*pig")
~r/man.+pig/
iex> Wildcard.to_regex("man*pig", match_type: :zero_or_more)
~r/man.*pig/
iex> Wildcard.to_regex("man****pig", match_type: :one)
~r/man....pig/