Regular Expressions, abbreviated as regex, are a beneficial tool add to one's skill set as a developer. Regex are patterns which match character combinations in strings and which can capture sections of strings for later use. This makes regex valuable for find-and-replace operations, form validation, cleaning input, and reformatting input. Using regex with string methods such as test()
, exec()
, match()
, and replace()
can open up new capabilities for working with strings, especially for newer developers. Regular expressions can be created using a regular expression literal, which uses a pattern wrapped in a forward slash (/
) before and after the pattern, or by using the Regular Expression constructor function. This article will use a regular expression literal to walk through some of the most fundamental components of regex.
The following regex pattern matches HTML elements and their tags, whether the element incl