U9 Topic 3 Flashcards
What are regular expressions
Patterns used to specify a set of strings
What are regular expressions used for
Finding particular words in a stream
Defining a set of acceptable strings in a language
How can this set be described
S = {a, ab, abb, abbb, …}
S = ab*
NOTATION -
* l *
Separates alternatives (or, V)
NOTATION -
* * *
Indicates there are 0 or more of the preceding element
NOTATION -
* + *
Indicates there are 1 or more of the preceding element
NOTATION -
* ? *
Indicates there are 0 or 1 of the preceding element
NOTATION -
* ( ) *
Used to identify Groupings
TRANSLATE -
a^+b^+
1 or more a and 1 or more b
TRANSLATE -
a^*b
0 or more a and b
TRANSLATE -
(a?b) l (ba^+)
1 group of 0 or 1 a and b, OR 1 group of, b and 1 or more a
DEFINE -
a “01” pair repeated any number of times
(01)^+
DEFINE -
One or more 0s bounded on either end by a single 1
10^+1
DEFINE -
S = {10, 100, 1000, … 01, 011, 0111, …}
10^+ l 01^+