Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/orsinium-labs/re
Elixir library for writing readable regexes in functional style
https://github.com/orsinium-labs/re
elixir elixir-lang erlang fp macro metaprogramming pcre re regex regexp regular-expression
Last synced: about 1 month ago
JSON representation
Elixir library for writing readable regexes in functional style
- Host: GitHub
- URL: https://github.com/orsinium-labs/re
- Owner: orsinium-labs
- License: mit
- Created: 2022-05-11T12:50:52.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-05-31T13:08:54.000Z (over 2 years ago)
- Last Synced: 2024-11-06T10:37:00.574Z (about 2 months ago)
- Topics: elixir, elixir-lang, erlang, fp, macro, metaprogramming, pcre, re, regex, regexp, regular-expression
- Language: Elixir
- Homepage: https://hexdocs.pm/re/
- Size: 25.4 KB
- Stars: 43
- Watchers: 4
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Re
Elixir library for writing regular expressions in functional style.
Features:
* Readable and human-friendly.
* Less error-prone.
* 100% compile-time, no overhead in runtime.
* But will fallback to runtime if needed (if you use dynamic content like variables).
* Well documented with lots of examples.
* Optimized and readable output.## Installation
The package can be installed by adding `re` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:re, ">= 1.0.0"}
]
end
```## Usage
```elixir
iex> require Re
iex> require Re.Chars
iex> regex =
...> Re.sequence([
...> Re.one_or_more(Re.any_of([Re.Chars.any_ascii, Re.any_of('.-_')])),
...> Re.text(".example.com")
...> ]) |> Re.compile()
~r/(?:[\\0-\x7f]|\.|\-|_)+\.example\.com/
iex> "hello.example.com" =~ regex
true
```**Documentation**: [hexdocs.pm/re/](https://hexdocs.pm/re/Re.html)