Question: The letters ' ab ' indicate that those two exactly should occur in sequence, and the bracketing around [ cd ] indicates that one of

The letters 'ab' indicate that those two exactly should occur in sequence, and the bracketing around [cd] indicates that one of those letters in the bracket should occur after for a sequence of 3 characters to be considered valid. Given the string
jpowabdopwajdabcowaigwmadabddba
This regular expression would accurately identify
jpowabdopwajdabcowaigwmadabddba
It is a fact that any regex is equivalent to a finite automata and vice versa by a result known as Kleene's theorem. Although the specifics of the proof are not at the level of this class, we can practice the creation of finite automata through regular expressions. For example, the regular expression we have seen so far can be converted to a finite state machine with the following transition diagram:
Figure 1: A FSM modeling the regex /\(\mathrm{ab}[\mathrm{cd}]\)/ where * is used to denote "any other input". For each regular expression below, create a transition diagram that captures its behavior. Draw out the diagram using a double circle to indicate the 'accept state', where the sequence of characters is accepted. If you are interested in creating your own regex, regexone is an online resource that helps you learn the pattern rules.
1./[0-9]a/, a regex capturing all occurrences of any digit from 0 to 9 then the letter a.
2./ab?c/, a regex where the occurrence of the letter b is optional. For example, both 'abc' and 'ac' would match under this regex.
3./[ab]+ or 'b's ending with a period. (In this regex, the period must be escaped because the '.' symbol on its own has another meaning).
4./[0-9]+/, a regex capturing a sequence of digits of length 1 or more
The letters ' ab ' indicate that those two

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!