Shared Flashcard Set

Details

Regex
Regular Expressions
52
Computer Science
Not Applicable
07/21/2019

Additional Computer Science Flashcards

 


 

Cards

Term
What is the regular expression equal to "Match any digit you find in the range 0 through 9."?
Definition
[0-9]
Term
This will match what: [0-9][0-9][0-9]-[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]
Definition
A US phone number
Term
This will match what: [0-9]
Definition
A single digit from 0 to 9.
Term
A simpler (shorthand) way of typing [0-9] is to type:
Definition
\d
Term
This will match what: \d\d\d-\d\d\d-\d\d\d\d
Definition
A US phone number
Term
The \D matches what?
Definition
Any non-digit character
Term
The _____ essentially acts as a wildcard and will match any character.
Definition
dot (.)
Term
A part of a pattern can be enclosed in parentheses (...). This is called a _____.
Definition
capturing group
Term
A _____ refers back to what was captured in the group enclosed by parentheses.
Definition
backreference
Term
The \1 in this regular expression is called a what? And what does it do: (\d)\d\1
Definition
A "backreference"; it references the \d in the parenthesis.
Term
What is '{3}' portion called in this regular expression: \d{3}
Definition
It's called a "quantifier" and it represents the number of occurrences of whatever is matched in front of it.
Term
The question mark (?) quantifier immediately following a character means what?
Definition
"match zero or one instance of this character".
Term
This will match what: \w
Definition
Letters and numbers
Term
What is the expression for matching non-word characters? (whitespace, punctuation, special characters)
Definition
\W
Term
What will this expression match: \b
Definition
\b allows you to perform a "whole words only" search using a regular expression in the form of \bword\b.
Term
What will this expression match: [\b]
Definition
A backspace character
Term
What will this expression match: \cX
Definition
ASCII control character; the second letter is an uppercase letter A through Z, to indicate Control+A through Control+Z.
Term
What will this expression match: \t
Definition
horizontal tab character; ASCII 0x09
Term
What will this expression match: \r
Definition
carriage return; ASCII 0x0D
Term
What will this expression match: \n
Definition
new line character; ASCII 0x0A
Term
What will this expression match: \R
Definition
A special escape that matches any line break, including Unicode line breaks. What makes it special is that it treats CR\LF pairs as indivisible.
Term
What will this expression match: \xHH
Definition
Hexidecimal ASCII characters (replace <HH> with 2-digit hex value). "A" is 41 in hex, so "\x41" will match all capital A's.
Term
What will this expression match: \s
Definition
Space character
Term
What will this expression match: \w
Definition
Word character
Term
What will this expression match: \W
Definition
Non-word character
Term
What will this expression match: \0
Definition
Nul character
Term
What will this expression match: [^\s\t\n\r]
Definition
Every character that is NOT a space, a tab, a newline, or carriage return.
Term
What will this expression match: ^The
Definition
matches any string that starts with "The"
Term
What will this expression match: end$
Definition
matches a string that ends with "end"
Term
What will this expression match: ^The end$
Definition
exact string match; starts and ends with "The end".
Term
What will this string match: ing
Definition
Matches any string that has the text "ing" anywhere in it.
Term
What will this expression match: abc*
Definition
Matches a string that has "ab" followed by zero or more characters.
Term
What will this expression match: (?i)the (?=horse)
Definition
It's a "Positive Lookahead"; every instance of "the" that is also followed by the word "horse".
Term
What will this expression match: (?i)the (?!horse)
Definition
It's a "Negative Lookahead"; every instance of "the" that is NOT followed by the word "horse".
Term
What will this expression match: ^alpha
Definition
It will match the word alpha, but only if it occurs at the very beginning of the subject text.
Term
What will this expression match: there$
Definition
The word "there" IF it's at the end of a line.
Term
The regular expression tokens ‹^›, ‹$›, ‹\A›, ‹\Z›, and ‹\z› are called _____.
Definition
anchors
Term
What will this expression match: \band\
Definition
It will match the word "and" by itself, but not the letters as part of a larger word.
Term
What will this expression match: \Band\B
Definition
It will match the letters a-n-d as part of a word, but not the word "and" by itself.
Term
What will this expression match: \b(?i:Jim|James|Jimmy)\b
Definition
It will match all instances of "Jim", "James", or "Jimmy".
Term
What will this expression match: \b[a-f0-9]{1,8}\b
Definition
Hexidecimal number
Term
What will this expression match: \bcolou?r\b
Definition
It will match "color" or "colour".
Term
What will this expression match: \b[bcr]at\b
Definition
Bat, cat, or rat
Term
What will this expression match: \b\w*phobia\b
Definition
Words ending with “phobia”
Term
What will this expression match: \bSte(?:ven?|phen)\b
Definition
Steve, Steven, or Stephen
Term
What will this expression match: \b(?!cat\b)\w+
Definition
Find every instance of the letters c-a-t, except the word "cat".
Term
What will this expression match: \b(?:(?!cat)\w)+\b
Definition
Matches any word that does NOT contain c-a-t
Term
What will this expression match: \b([A-Z]+)\s+\1\b
Definition
Repeated words (like "the the").
Term
The notation using square brackets is called a _____ and it matches a single character out of a list of possible characters.
Definition
character class
Term
A _____ negates a character class if you place it immediately after the opening bracket.
Definition
caret (^)
Term
A _____ creates a range when it is placed between two characters.
Definition
hyphen (-)
Term
What will this expression match: /^[a-z0-9_-]{3,16}$/
Definition
It will match a username with three to sixteen characters, having letters, numbers, underscores, and hyphens.
Supporting users have an ad free experience!