Online regular expression testing tool
Common metacharacters
Code Description . Matches any character except newline \w Matches a letter, digit, or underscore \s Matches any whitespace character \d Matches a digit \b Matches the beginning or end of a word ^ Matches the beginning of a string $ Matches the end of a string
Common quantifiers
Code Description * Repeats zero or more times + Repeats one or more times ? Repeats zero or one time {n} Repeats n times {n,} Repeats n or more times {n,m} Repeats from n to m times
Common antonyms
Code Description \W Matches any character that is not a letter, digit, underscore, or Chinese character \S Matches any character that is not a whitespace character \D Matches any character that is not a digit \B Matches a position that is not the beginning or end of a word [^x] Matches any character except x [^aeiou] Matches any character except the letters aeiou
Regular expression modifiers
Tags, also known as modifiers, are used in regular expressions to specify additional matching strategies. Tags are not written within the regular expression; they are located outside the expression, in the following format:
/pattern/flags
i ignore - Case-insensitive Set the match to be case-insensitive; there is no distinction between upper and lower case during the search: A and a are the same. g global - Global match Finds all matching items. m multi line - Multi-line match Makes the boundary characters ^ and $ match the beginning and end of each line, remember it's multiple lines, not the beginning and end of the entire string. s Special character dot. includes newline \n