构造(ab)*(aabb)(ab)*的DFA,解题过程中有处疑问。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了构造(ab)*(aabb)(ab)*的DFA,解题过程中有处疑问。相关的知识,希望对你有一定的参考价值。

在第二步NFA转化为DFA中,q0等于0,4,2而不是0,4,2,3,7,1对吗?

参考技术A q0等于0,4,2,空字闭包中状态的集合为从状态出发经过任意条空字弧所到达的状态;2状态不可能跨越非空字弧到达3状态,所以初始状态子集q0等于0,4,2。

JS正则手机靓号处理AB ABAB AABB

靓号检测:主要可以检测连号(正连 12345、倒连65432)、AABB号、手机号码、日期号(生日号、年度号)、ABBCABB号,3位以上重复号。 更多类型号码检测可以根据以下表达式改造。
1.匹配6位顺增   (?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){5}\d  2.匹配6位顺降  (?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){5}\d  3.匹配6位顺增或顺降  (?:(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){5}|(?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){5})\d    4.匹配4-9位连续的数字  (?:(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3,}|(?:9(?=8)|8(?=7)|7(?=6)|6(?=5)|5(?=4)|4(?=3)|3(?=2)|2(?=1)|1(?=0)){3,})\d    5.匹配3位以上的重复数字  ([\d])\1{2,}    6.匹配日期类型的数字  (19|20)[\d]{2}(1[0-2]|0?[1-9])(31|2[0-9]|1[0-9]|0?[0-9])    7.手机号码类  (13[0-9]|15[0-9]|18[0-9])([\d]{2,4}){2}    8.匹配33111类型的  ([\d])\1{1,}([\d])\2{2,}    9.匹配5331533类型的  (([\d]){1,}([\d]){1,})\1{1,}    10,匹配22334,123355类型的  ([\d])\1{1,}([\d])\2{1,}    11.末位匹配$ //aabb,允许aaaa (\d)\1(\d)\2$ //abab,允许aaaa (\d)(\d)\1\2$ //aaab,允许aaaa (\d)\1\1\d$ //同时允许 (?:(\d)\1(\d)\2|(\d)(\d)\3\4|(\d)\5\5\d)$ //以上如果不允许aaaa,第二个(\d)改为((?!\1)\d) //如aabb,不允许aaaa (\d)\1((?!\1)\d)\2$ var reg = new RegExp("(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){5}\\d", "g"); if (phone.match(reg) != null) { code +=‘,ABCDEF‘; } var reg = new RegExp("(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\\d", "g"); if (phone.match(reg) != null) { code += ‘,ABC‘; } var reg = new RegExp("^(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\\d[\\d][\\d](?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\\d", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(0, 3) == result.substring(5,8)) { code += ‘,ABC**ABC‘; } } var reg = new RegExp("[\\d](?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\\d[\\d](?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\\d$", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(1, 4) == result.substring(5, 8)) { code += ‘,*ABC*ABC‘; } } var reg = new RegExp("(\\d)((?!\\1)\\d)\\2[\\d]", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(0, 1) == result.substring(3, 4)) { code += ‘,ABBA‘; } } var reg = new RegExp("(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\\d{4}", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(0, 3) == result.substring(3, 6)) { code += ‘,ABCABC‘; } } var reg = new RegExp("^(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\\d{4}", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(0, 3) == result.substring(3, 6)) { code += ‘,ABCABC*‘; } } var reg = new RegExp("(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){2}\\d{3}", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(0, 2) == result.substring(3, 5)) { code += ‘,ABCAB‘; } } var reg = new RegExp("(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3}\\d", "g"); if (phone.match(reg) != null) { code += ‘,ABCD‘; } var reg = new RegExp("(?:0(?=1)|1(?=2)|2(?=3)|3(?=4)|4(?=5)|5(?=6)|6(?=7)|7(?=8)|8(?=9)){3}\\d{5}", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(0, 4) == result.substring(4, 8)) { code += ‘,ABCDABCD‘; } } var reg = new RegExp("(\\d)((?!\\1)\\d)\\1\\2\\1\\2", "g"); if (phone.match(reg) != null) { code += ‘,ABABAB‘; } var reg = new RegExp("^(\\d)((?!\\1)\\d)\\1\\2\\1\\2", "g"); if (phone.match(reg) != null) { code += ‘,ABABAB*‘; } var reg = new RegExp("(\\d)((?!\\1)\\d)\\1\\2", "g"); if (phone.match(reg) != null) { code += ‘,ABAB‘; } var reg = new RegExp("^(\\d)((?!\\1)\\d)[\\d][\\d](\\d)((?!\\1)\\d)[\\d][\\d]", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(0, 2) == result.substring(4, 6)) { code += ‘,AB**AB**‘; } } var reg = new RegExp("[\\d][\\d](\\d)((?!\\1)\\d)[\\d][\\d](\\d)((?!\\1)\\d)$", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(2, 4) == result.substring(6, 8)) { code += ‘,**AB**AB‘; } } var reg = new RegExp(‘([\\d])\\1{4,}‘, "g"); if (phone.match(reg) != null) { code +=‘,AAAAA‘; } var reg = new RegExp(‘(.)\\1{3}‘, "g"); if (phone.match(reg) != null) { code +=‘,AAAA‘; } var reg = new RegExp(‘(\\d)\\1\\1((?!\\1)\\d)‘, "g"); if (phone.match(reg) != null) { code += ‘,AAAB‘; } var reg = new RegExp(‘(.)\\1{2}‘, "g"); if (phone.match(reg) != null) { code +=‘,AAA‘; } var reg = new RegExp(‘(.)\\1{1}‘, "g"); if (phone.match(reg) != null) { code +=‘,AA‘; } var reg = new RegExp("(\\d)\1((?!\\1)\\d)\\2\\2", "g"); if (phone.match(reg) != null) { code +=‘,AABBB‘; } var reg = new RegExp("(\\d)\\1((?!\\1)\\d)\\2", "g"); if (phone.match(reg) != null) { code +=‘,AABB‘; } var reg = new RegExp("(\\d)\\1((?!\\1)\\d)((?!\\1)\\d)\\3", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(2, 3) != result.substring(0, 1) && result.substring(2, 3) != result.substring(3, 4)) { code += ‘,AABCC‘; } } var reg = new RegExp("(\\d)\\1((?!\\1)\\d)\\2((?!\\1)\\d)\\3", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(2, 4) != result.substring(0, 2) && result.substring(2, 4) != result.substring(4, 6)) { code += ‘,AABBCC‘; } } var reg = new RegExp("^(\\d)\\1((?!\\1)\\d)\\2((?!\\1)\\d)\\3", "g"); if (phone.match(reg) != null) { var result = phone.match(reg).toString(); if (result.substring(2, 4) != result.substring(0, 2) && result.substring(2, 4) != result.substring(4, 6)) { code += ‘,AABBCC*‘; } }

 


以上是关于构造(ab)*(aabb)(ab)*的DFA,解题过程中有处疑问。的主要内容,如果未能解决你的问题,请参考以下文章

请给正规式a(ab)*abb转变成DFA。(提示:先转变成NFA,再用子集法确定化并化简)?

帮忙解下编译原理题

ARC127F±AB

文法与语言

DFA化简

为给定的正则表达式绘制最小 DFA