doggie v0.1.0 Doggie.Patterns
Doggie is a library that provides the most commonly used regular expression patterns, such as patterns for email, ip, isbn and etc.
This library can be useful if you don’t want to write regular expression manually.
Summary
Functions
Pattern for for matching email address
Pattern for matching bitcoin address
Pattern that match ISBN 10 and ISBN 13
Pattern for matching mac address
Pattern for matching phone number for United States of America
Pattern that matches roman numerals
Pattern for matching 24 hour time format
Pattern for matching zip code of cuntry
Functions
Pattern for for matching email address.
Examples
iex> Regex.match?(Doggie.email(), "likid.geimfari@gmail.com")
true
iex> Regex.match?(Doggie.email(), "likid.geimfari@gmai'l.com")
false
Pattern for matching bitcoin address
Examples
iex> Regex.match?(Doggie.hex_value(), "#a3c113")
true
iex> Regex.match?(Doggie.hex_value(), "a3c113")
true
Pattern that match ISBN 10 and ISBN 13.
Examples
iex> Regex.match?(Doggie.isbn(), "ISBN-13: 978-1-56619-909-4")
true
iex> Regex.match?(Doggie.isbn(), "ISBN-13: 978 5 93286 159 2")
true
iex> Regex.match?(Doggie.isbn(), "978-1-56619-909-4")
true
iex> Regex.match?(Doggie.isbn(), "ISBN-10: 1-56619-909-3")
true
iex> Regex.match?(Doggie.isbn(), "1-56619-909-3")
true
iex> Regex.match?(Doggie.isbn(), "978 1 56619 909 4")
true
iex> Regex.match?(Doggie.isbn(), "ISBN 13: 978-1-56619-909")
false
Pattern for matching mac address.
Examples
iex> Regex.match?(Doggie.mac_address(), "00:08:C7:1B:8C:02")
true
iex> Regex.match?(Doggie.mac_address(), "00:08:C7:1B:8C")
false
Pattern for matching phone number for United States of America.
Examples
# Phone number without country code.
iex> Regex.match?(Doggie.phone_number(:us), "2345678901")
true
# Phone number with space separators.
iex> Regex.match?(Doggie.phone_number(:us), "1 234 567 8901")
true
# Phone number with dash separators.
iex> Regex.match?(Doggie.phone_number(:us), "1-234-567-8901")
true
# Phone number with mixed separators.
iex> Regex.match?(Doggie.phone_number(:us), "1 (234) 567-8901")
true
# Invalid phone number
iex> Regex.match?(Doggie.phone_number(:us), "+45 12 23 45 67")
false
Pattern that matches roman numerals.
Examples
iex> Regex.match?(Doggie.roman_numerals(), "XX")
true
iex> Regex.match?(Doggie.roman_numerals(), "20")
false
Pattern for matching 24 hour time format.
Examples
iex> Regex.match?(Doggie.time_24_format(), "23:00")
true
iex> Regex.match?(Doggie.time_24_format(), "25:00")
false
Pattern for matching zip code of cuntry.
Examples
iex> Regex.match?(Doggie.zip_code(:ru), "454356")
true
iex> Regex.match?(Doggie.zip_code(:ru), "4543563")
false
iex> Regex.match?(Doggie.zip_code(:ru), "43564")
false
iex> Regex.match?(Doggie.zip_code(:is), "356")
true
iex> Regex.match?(Doggie.zip_code(:is), "35464")
false
iex> Doggie.zip_code(:python)
{:error, :unsupported_country}