Regular Expressions Flashcards
What does the regex operator ^ signify?
The ^ operator signifies the start of a line or string. It is used to match a pattern only if it appears at the beginning.
What does the regex operator $ signify?
The $ operator signifies the end of a line or string. It is used to match a pattern only if it appears at the end.
What does the regex operator . signify?
The . operator matches any single character except a newline. It acts as a wildcard in regex.
What does the regex operator * signify?
The * operator matches zero or more occurrences of the preceding character or group. For example, a* matches ‘’, ‘a’, ‘aa’, etc.
What is the function of the regex operator *?
The * operator matches zero or more occurrences of the preceding character or group. It allows for repetition, including none at all.
What does the regex operator + signify?
The + operator matches one or more occurrences of the preceding character or group. For example, a+ matches ‘a’, ‘aa’, ‘aaa’, etc.
What does the regex operator ? signify?
The ? operator matches zero or one occurrence of the preceding character or group. For example, colou?r matches both ‘color’ and ‘colour’.
What does the regex operator [] signify?
Square brackets [] define a character set and match any one character within the set. For example, [abc] matches ‘a’, ‘b’, or ‘c’.
What does the regex operator [^ ] do?
The [^ ] operator defines a negated character set and matches any character not in the set. For example, [^abc] matches any character except ‘a’, ‘b’, or ‘c’.
What does the regex operator | signify?
The | operator acts as an OR condition and matches either pattern on its sides. For example, cat|dog matches ‘cat’ or ‘dog’.
What does the regex operator () signify?
Parentheses () are used for grouping patterns. They allow regex operators to act on the entire group as a unit.
What does the regex operator \d signify?
The \d operator matches any digit (0–9). It is equivalent to the character set [0-9].
What does the regex operator \D signify?
The \D operator matches any non-digit character. It is equivalent to the negated set [^0-9].
What does the regex operator \w signify?
The \w operator matches any word character (alphanumeric and underscore). It is equivalent to [a-zA-Z0-9_].
What does the regex operator \W signify?
The \W operator matches any non-word character. It is equivalent to the negated set [^a-zA-Z0-9_].
What does the regex operator \s signify?
The \s operator matches any whitespace character, such as spaces, tabs, or newlines.
What does the regex operator \S signify?
The \S operator matches any non-whitespace character.
What does the regex operator {n} signify?
The {n} operator matches exactly ‘n’ occurrences of the preceding character or group. For example, a{3} matches ‘aaa’.