Regular Expression Reading

64 Views Asked by At

I'm trying to figure out what this regular expression reads as. The regular expression is the following:

(0(1 + 2) * 00*) (+ = union) (* = zero or many).

I believe this reads as: 0 concatenated with zero or many 1s or 2s concatenated with one or many zeros. Am I correct? I apologise if this seems basic but I think the answer should be fairly straightforward for someone experienced in regular expressions to answer.

1

There are 1 best solutions below

1
On BEST ANSWER

I think your reading is probably correct.

I would have said "zero or more" and "one or more" rather than "zero or many" and "one or many", because otherwise it might not be clear that you are using "many" to mean "one or more". The expression $$0^\ast$$ includes the case of two zeroes, but most people would not understand "many" to mean "two".