Regex Cheat Sheet: Meta Characters - What Meta Characters Mean

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 1

RegEX Cheat Sheet

Meta Characters - [,\,^,$,.,|,?,*,+, ( ,), -. What Meta Characters mean [ ] \ ^ Opens a character class Closes a character class Delimits the following character or can be used like this \xFF to define a character by its hexadecimal value Inside of a character class this indicates that the next character is negated and outside indicates that the pattern is tied to the beginning of the line $ . | ? * + ( Ties a pattern to the end of a line Matches any character except a line break, it is considered lazy and not good form to use this Used to indicate an XORed set of possible pattern matches Makes the proceeding term optional, so abc? Will match ab or abc Repeats the proceeding item 0 or more times, so .* matches def and ghi in abc def ghi jkl Repeats the previous item one or more times, so \d+ matches 111 in 111 12a 12b Creates a back reference, essentially used to store something in a variable(may or may be implemented in the RegEX engine you are using) ) Closes a back reference Indicates a range in a character class, [0-9] matches a single digit from 0 to 9

Other useful RegEx syntax \n \r Matches a Line Feed/New Line Matches a Carriage Return(NOTE: For UNIX only the \n is necessary to indicate the end of a line, but for Microsoft \n\r is necessary) \t \s \d \w Matches a tab character Matches white space Matches a digit Matches letters or digits in some implementations of RegEx engines

NOTE: Any of the above capitalized negates it, or makes it match the opposite, except \r, \n, and \t \A \Z \b {n} Matches the beginning of a string Matches the end of a string Matches at the position between a word character and a non-word character Repeats the previous pattern n number of times

{n,m} Repeats the previous pattern between n and m times where n is the minimum and m is the maximum

You might also like