A regex, which is short for regular expression, is a sequence of characters that defines a specific search pattern. When included in code or search algorithms, regular expressions can be used to find certain patterns of characters within a string, or to find and replace a character or sequence of characters within a string.
Below we will discuss how to implement a regular expression to find an email matching the search criteria. Using the following, /^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$/, I will detail the various components of the regex and explain what is occuring. Regular expressions begin and end with forward slashes, /, in order to indicate the search parameters and define itself as a regex.