Regex 101 Flashcards
What is Regex?
Short for regular expression, a regex is a string of text that allows you to create patterns that help match, locate, and manage text.
What is the left and the right side of this called?:
action=time532
field and value
Both they create a field-value pair
What does Regex do?
a) Filtering - it eliminates unwanted data from your searches
b) Matching - advanced pattern matching to find the results you need
c) Field extraction - labels bits of data that can be used for further calculation and analysis
What does Control Characters (anchors) do?
They tell regex where to start and stop looking
What control characters do you know? What do they do?
^ - start of a line
$ - end of a line
\b - whole words only
\B - bordered by word characters
What are character Classes?
Character classes distinguish kinds of characters such as, for example, distinguishing between letters and digits
What are the character classes that you know? What do they do?
\s - white space
\S - not a white space
\d - digit
\D - non-digit
\w -word-character (includes letters, numbers and underscore)
\W - non-word character
How to define symbolic character?
use \
How to anchor start of a line?
How to anchor end of a line?
$
How to define the border by whole words only?
\b
How to define the border by word characters?
\B
What’s the character class for white space?
\s
What’s the character class for not a white space?
\S
What’s the character class for digit?
\d
What’s the character class for non-digit?
\D
What’s the character class for word-character?
\w
What’s the character class for non-word character?
\W
What are operators?
They define how many of character types to grab
What operators you know? What do they do?
* - zero or more
+ - one or more
? - Zero or more
What is the Operator for zero or more?
*
What is the operator for one or more?
+
What is the operator for zero or one?
?
What is a Greedy regex?
Greedy regex means that your regex statement is using a operator that keeps gobbling up matches until it is interrupted
What is a Lazy regex?
Lazy regex means your regex will only match the first occurence of the pattern you are looking for before it stops
What are special characters?
Those are the characters that symbolize something else.
For Example *+?$/[]{}()
What is the symbol for “OR” condition?
|
What is the special character for matching any character?
.
What is a protection character?
It identifies given letter as a special character, or special character as a literal match