I'm facing a problem when I'm trying to parse string containing FSM defined as:
{{states},{symbols}, {transitions}, starting_symbol, {set of finishing states}}
example:
{{start, mid, end}, {'a', 'b'}, { start 'a' -> end}, start, {end}}
As opposed to writing a parser here, I would like to parse this via regular expressions.
My problem lies in understanding regex matching groups and how to break string such as "start, mid, end"
into array [ "start", "mid", "end" ]
(assuming delimiter ,
).
I understand that using builtin csv functions might be better idea, but example is bit more complex (albeit for simplicity sake lets assume that each member of set can be matched by \w
.
Any help would be appreciated.