
\w\w\w ≠ boat // Doesn't return boat because boat contains 4 characters. To use a special character as a regular one, prepend it with a backslash. Escape sequences like \:, \-, \ will be equivalent to their literal, unescaped character equivalents in regular expressions. neither have a special meaning when escaped nor when unescaped. Note that some characters like :, -,, etc. The special character after the closing square bracket specifies to match zero or more occurrences of the character set. To match literally, precede it with a backslash for example, /a\/ matches 'a'. Let’s say we want to find literally a dot. The regular expression A-Z a-z matches any sequence of letters that starts with an uppercase letter and is followed by zero or more lowercase letters. Allows the regex to match the word if it appears at the beginning of a line, with no characters before it. It prevents the regex from matching characters before or after the words or phrases in the list. This s also called “escaping a character”. W matches any character that’s not a letter, digit, or underscore. īackslash (\) in a regular expression to remove the meaning of a meta character. \w : Matches any word character including underscore.\S : Matches any non-white space character.\s : Matches any white space including spaces, tabs, form-feed characters, and so on.\r : Matches a carriage return character.: Matches any character that is not enclosed.Matches any one of the enclosed characters. For example, matches any character that is not in the range m through z. : Matches any character that is not in the specified range.For example, matches any lowercase alphabetic character in the English alphabet. : Matches any character in the specified range.Matches the preceding character at least n and at most m times. : The m and n variables are non-negative integers.? : Matches the preceding character zero or one time.+ : Matches the preceding character one or more times.* : Matches the preceding character zero or more times.Quantifiers can be used to specify number of times a token should be matched by the regex engine. (abc) : Character group, matches the characters abc in that exact order.\b : Matches a word boundary, that is, the position between a word and a space.\A : Matches only at beginning of a string, or before a newline character at the end.\Z : Matches only the end of a string, or before a newline character at the end.$ : Matched end of the string or before \n at the end of the string in multiline mode, it must occur at the end of the line or before \n at the end of the line.^: Matches beginning of the string in multiline mode, it must occur at the beginning of the line.: Matches any single character except a newline character. The sequence \\ matches \ and \( matches (. For example, n matches the character n, whereas \n matches a newline character. \ : Marks the next character as either a special character or a literal.The following are some common RegEx meta characters and examples of what they would match or not match in RegEx. Characters in RegEx are understood to be either a meta character with a special meaning or a regular character with a literal meaning. Meta characters are the building blocks of regular expressions.
