Now that we have a general idea how Regex works (visit my simple Regex tutorial). Let's break down what's happening in the Email Regex example above.
The anchor used in this regex for email is the
^, which indicates the beginning of a string and the
$, indicating the end of a string. Next, lets focus our attention to the
(grouping/capturing which occurs between parenthesis). In group one, (remember group zero is the whole entity together as one) we see
([a-z0-9_\.-]). This matches the email name. Furthermore, we can tell because inside the brackets, it is matching any character in the range "a" to "z", any digits 0-9, underscore character which matches _ , the \ indicates an excape matching a . , and last the - character matching a -. Next, we noticed what every email has the
@ symbol, which means without this matching, it wouldn't be an email! We move to