简体   繁体   English

正则表达式 [ 1 ( 0 1* 0)* 1 ]* DFA

[英]Regular expression [ 1 ( 0 1* 0)* 1 ]* DFA

这个正则表达式接受链的条件是什么?

The * at the end can be taken to mean the initial state is accepting and that the automaton returns to this state whenever it accepts anything.末尾的 * 可以表示初始状态正在接受,并且自动机在接受任何内容时都会返回到该状态。 Call the initial state q1.调用初始状态 q1。

To accept 1(01*0)1 we must first consume a 1 and go to a new state, say q2.要接受 1(01*0)1,我们必须首先消耗 1 并进入一个新状态,比如 q2。 From there, we can self-loop on the subexpression 01*0 by going to a new state, q3, on 0, then looping on 1 in q3, then returning to q2 on 0.从那里,我们可以在子表达式 01*0 上自循环,方法是在 0 上进入一个新状态 q3,然后在 q3 中的 1 上循环,然后在 0 上返回到 q2。

From q2, we can return to q0 on 1. Our DFA looks like:从 q2,我们可以在 1 上返回到 q0。我们的 DFA 看起来像:

     /--1--\  /--0--\
     |      \ |     |
     V      | V     |
--->(q1)-1->(q2)-0->(q3)-\
     |               ^    \
     0               |    /
     |               \-1-/
     V
    (q4)-\
     ^    \
     |    /
     \0,1/

Something like that ought to do it.应该做这样的事情。

When you don't know how to start off, you should write down several first elements generated by regular expression.当你不知道如何开始时,你应该写下正则表达式生成的几个第一个元素。 In this case:在这种情况下:

SET = {eps, 11, 1001, 10101, ...}

and then try to make up something.然后尝试弥补一些东西。 You got the answer though, so I'm not going to repeat this.你得到了答案,所以我不会重复这个。

May you get some idea可能你有什么想法

\[[0-9\s]+.*\]\*

Demo: https://rubular.com/r/n3bVXJd3SFffr0演示: https : //rubular.com/r/n3bVXJd3SFffr0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM