4.4.2.3 Regular expressions and 4.4.2.4 Regular language Flashcards
What does [A-Z] / [0-9] mean?
exactly one instance of a capital letter
exactly one instance of 0-9
What does + mean?
Matches between one and unlimited times
What does * mean?
Matches between zero and unlimited times
What does ? mean?
0 or 1 repetitions, ie optional
What does | mean?
or
What does \d or \s mean?
Any digit
any whitespace character
What is the relationship between
regular expressions and FSMs.
Regular expressions and FSMs are equivalent
ways of defining a regular language.
What is a regular language?
if it can be represented by a regular expression.
any language that a FSM will accept.
What is a:
natural language
formal language ?
Natural - comprises of a set of words written and spoken by humans
Formal - Used for the precise definition of syntactically correct programs for a programming language
The alphabet is defined as a finite set of symbols
The rules of syntax define how to construct strings of the language out of symbols
It is not feasible to list all the strings. Instead Regular expressions are used.
What is a regular expression?
expressing the language that a machine can use in a formal manner
They provide a means of identifying if a string of characters is allowed in a particular language
What does n[^t] mean?
An n followed by a character that is not a t