REGEX Commands Cheat Sheet
Here is a cli commands cheat sheet for REGEX command, you can use this as a quick reminder for basic commands with a brief description for each of the commands.
What is REGEX command?
Add some data here
# BRACKETS: [...]: Any one character between the brackets. [^...]: Any one character not between the brackets. [0-9]: It matches any decimal digit from 0 through 9. [a-z]: It matches any character from lowercase a through lowercase z. [A-Z]: It matches any character from uppercase A through uppercase Z. [a-Z]: It matches any character from lowercase a through uppercase Z. # QUANTIFIERS: p+: It matches any string containing at least one p. p*: It matches any string containing zero or more ps. p?: It matches any string containing one or more ps. p{N}: It matches any string containing a sequence of N ps. p{2,3}: It matches any string containing a sequence of two or three ps. p{2, }: It matches any string containing a sequence of at least two ps. p$: It matches any string with p at the end of it. ^p: It matches any string with p at the beginning of it. # LITERAL CHARACTERS: Alphanumeric: Itself. \0: The NUL character (\u0000). \t: Tab (\u0009). \n: Newline (\u000A). \v: Vertical tab (\u000B). \f: Form feed (\u000C). \r: Carriage return (\u000D). # METACHARACTERS: .: a single character. \s: a whitespace character (space, tab, newline). \S: non-whitespace character. \d: a digit (0-9). \D: a non-digit. \w: a word character (a-z, A-Z, 0-9, _). \W: a non-word character. [\b]: a literal backspace (special case). [aeiou]: matches a single character in the given set. [^aeiou]: matches a single character outside the given set. (foo|bar|baz): matches any of the alternatives specified. # Common REGULAR EXPRESSIONS: Matching a Username: ^[a-z0-9_-]{3,16}$ Matching a Password: ^[a-z0-9_-]{6,18}$ Matching a Hex Value: ^#?([a-f0-9]{6}|[a-f0-9]{3})$ Matching a Slug: ^[a-z0-9-]+$ Matching an Email: ^([a-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})$ Matching a URL: ^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$ Matching an IP Address: ^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$ Matching an HTML Tag: ^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$
Check out the REGEX command documentation .
You can also check our MegaSh cheatsheet tool, that has 150+ searchable linux cheat sheets in one page, so you never forget a command as you work again