1) Regular Expressions and Languages Flashcards
Regular Expressions
Regular expressions are patterns used to specify a set of strings.
They are used for;
- Finding particular words in a stream
- Finding combinations of characters in strings
Set and Notation Precedence
S can be defined by a regular expression ab*
S = {a, ab, abb, abbb}
| - Separates alternatives
* - Indicates that there are 0 or more of the preceding element.
+ - Indicated there is 1 or more of the preceding element.
? - Indicates that there are 0 or 1 of the preceding element.
( ) - used to identify groupings
What is a set?
A set is a well-defined collection of objects, objects in s set are called elements.
A set is unordered and each element can only occur once.
Common Sets:
N = Natural Number {0, 1, 2,…}
Z+ = Positive Integer {1, 2, 3,…}
Z = all integers {…, -2, -1, 0, 1, 2, …}
Q = rational numbers { number expressed as a fraction}
R = real numbers { Numbers that contain a decimal place}