Follow along the code samples and read the comments for understanding regular expressions
The code examples are primarily written in typescript (I prefer static typing) and then transpiled to javascript.
Typescript is very easy to understand, but if your are not sure about it, you can always check the good old javascript.
I have inserted comments wherever seemed fit.