No description, website, or topics provided.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Elixir Regular Expressions made easy. Ported from the JavaScript version VerbalExpressions.

Build Status

How to get started

Include the VerbalExpressions module (and alias it, if you want). Then simply check out the Examples and documentation to get started. It's easy :)


Here's a couple of simple examples to give an idea of how VerbalExpressions works:

Testing if we have a valid URL

# Create an example of how to test for correctly formed URLs
alias VerbalExpressions, as: VerEx
tester = VerEx.startOfLine()
         |> VerEx.then("http")
         |> VerEx.maybe("s")
         |> VerEx.then("://")
         |> VerEx.maybe("www")
         |> VerEx.anythingBut(" ")
         |> VerEx.endOfLine()
testMe = ""

result = tester |> VerEx.match?(testMe)

if result do
  IO.puts "Valid URL :)"
  IO.puts "Invalid URL :("

Replacing strings

# Create a test string
replaceMe = "Replace bird with a duck"

# Create an expression that seeks for word "bird"
expression = VerEx.find "bird"

# Execute the expression like a normal RegExp object
result = expression |> VerEx.replace replaceMe, "duck"

IO.puts result # Outputs "Replace duck with a duck"

Shorthand for string replace:

result = VerEx.find("red") |> VerEx.replace "We have a red house", "blue"

IO.puts result # Outputs "We have a blue house"

Method chaining

The original version of VerbalExpressions uses method chaining. This version of verbal expressions in Elixir does not only support the (nicer) |>-based chaining, but also has a record-based version for method-chaining support.

Here is the above string replace example using method chaining:

v =
result = v.find("red").replace("We have a red house", "blue")

IO.puts result # Outputs "We have a blue house"

API documentation

You can find the API documentation on it's own page.


Pull requests are welcome.


Please report any issues to the GitHub issuetracker.


Thank you to @jehna for coming up with the awesome original idea!