Regex
Example
Authors
Acknowledgments
A regular expression or (REGEX) is a sequence of characters that specifies a search pattern. Usually such patterns are used by string-searching algorithms for "find" or "find and replace" operations on strings, or for input validation. It is a technique developed in theoretical computer science and formal language theory.
- What does this Regex mean step by step?
- / Opening and closing any Regex with a forward slash / is a necessity.
- ^ at the beginning and $ at the end means that the following inout is a string, which are called anchors. It starts with ^ and ends with $.
- [a-z0-9_.-] This means that the email can contain letters from a-z, numbers from 0-9, _.- means that the email can contain an underscore, dash, any special character, period, and a dash.
-
- sign indicates (one or more) of the characters a rule in the Regex.
- @ This means that after the initial rule, and @ sign is needed.
- [\da-z.-]+ means that the input can contain one or more digits, and letters from a-z, any special characters(.) and dashes.
- [a-z.] means that the input can contain a letter from a-z, a speical character.
- {2,6} means that the input shpuld be between 2-6 characters.
- Mehdi Safari