Product of Lexical Specification I have a problem that asks me to consider the string abbbaacc. I'm supposed to figure out which of the following lexical specification produces the tokenization ab/bb/a/acc.

The options are:

A.
    a(b+c)*
    b+

B.
    ab 
    b+
    ac*

C.
    c* 
    b+
    ab
    ac*

D.
    b+ 
    ab*
    ac*


I just learned about REGEX, and I'm not sure about this, but to solve this problem would I just be trying see which options can make ab/bb/a/acc?

If that's correct, then would the answer be all four of them?

Since all four of them can match to ab/bb/a/acc:

A.
     a(b+c)* -&gt; a, ab, acc 
     b+ -&gt; bb
B. 
     ab -&gt; ab
     b+ -&gt; bb
     ac* -&gt; a, acc
C.
     c* -&gt; 
     b+ -&gt; bb
     ab -&gt; ab
     ac* -&gt; a, acc
D. 
     b+ -&gt; bb
     ab* -&gt; a, ab
     ac* -&gt; a, acc


I'm not sure if I'm doing this correctly.
There's not enough information here to answer the question, but I can prove a pretty good guess based on how tokenizers are typically implemented.  Generally the tokenizer will run through the list of patterns, trying each one I sequence.  If one of them matches it takes the longest possible match as a token, then starts over at the top of the list.  I surmise this is the implicit background for the question.

So forinstance if you have abbbaacc and the rules a(b|c)* and b+ in that order then you'd tokenize that as abbb/a/acc.