This SKB is about Regex, which stand for Regular Expression.
I will not explain the details about Regex in this article but feel free to look at those resources to learn more about it:
The first example is a simple case to check for a match. However the compilation of the regex into an actionable test can be costly. It is recommended to compile the regex once before using it several times. This is when the second example come into play.
The second example is more complex and involved. We describe a structure to hold the regex and build a case class from it. We can then build shortcut methods to make the interaction with the regex more intuitive.
The third example is leveraging pattern matching. You can see each group match in the regex
( ... ) is corresponding to a value in the pattern matching.