I have been studying regular expressions and have been working through a tutorial which asks me to construct the following;
a regular expression for all strings containing 101 as a sub string
a regular expression for the set of all strings without any consecutive 0’s
am I correct in thinking (0 + 01)* 1* would work for the first one or am I way off the mark? And how would I approach the second one? cheers in advance
No you are wrong if you use (0 + 01)* 1* .This would yield :
001 00001 000111
etc... but not 101. My advise would be to just draw the diagrams.It would definitely be useful for you to see what goes on. Btw the problems that you posted don't actually require a regex :)