While going through Elixir with a group of beginners, we got to a point I wanted to explain to them what a regex is. I thought of an analogy that they could relate with.
What if you think about Regex as a riddle with many solutions? For example:
- It has 4 legs
- It has 2 eyes
- It has a neck
- It has a tail
What is it?
The answer can be any of the following:
- Hyena
- Giraffe
- Goat
The answer is definitely not the following:
- Fish
- Snake
- Chicken
A regex is a set of rules that has a lot of answers