Add-On REGEX Flashcards
Show an example of the following anchors?
- Beginning of a string
- End of a string
- Word boundary
‘^SearchString’
‘SearchString$’
‘\bSearchString\b’
What are character classes for:
any lowercase letter
any uppercase letter
any letter
hexadecimal values
[[:lower:]]
[[:upper:]]
[[:alpha:]]
[[:alnum:]]
Regex example to check if only one char was entered?
’^[[:alpha:]]$’
Write a pattern that matches any word that begins with b, followed by a vowel, and ending with t.
\bb[aeiou]t\b
Match any digit or carat symbol
Match line that does not contain numbers
Match any line containing a digit
Match any line containing a minus, zero or nine
[0-9^]
[^0-9]
[0-9]
[-09]
What are the special character classes for:
[0-9] (digits)
[\t\r\n] (whitespaces)
[A-Za-z0-9_]
[[:digit:]]
[[:space:]]
[[:alnum:]]
Regex should check only one of the following words item0, item1….
^item[[:digit:]]$
Find any three character?
‘\b[[:alnum:]]\b’
Find any line that contains only one character?
’^[[:alnum:]]$’
Match any word that contains three lowercase letters?
‘\b[[:lower:]]{3}\b’
5 ‘a’ characters
5 or more ‘a’ characters
between 5 and 7 ‘a’ characters
between 3 and 5 lowercase characters
a{5}
a{5,}
a{5,7}
[[:lower:]]{3,5}
What is the shorthand version of:
a{0,} - zero ore more
a{1,} - one or more
a{0,1} - zero or one
a*
a+
a?
Find any number, whether it’s a whole number or a decimal
’[[:digit:]]+.?[[:digit:]]*’
Search for dog or cat or fish
dog|cat|fish
Search for cat or bat?
cat|bat
[cb]at