自动机和正则表达式的一些算法实现
automaton-tools的Python项目详细描述
简介
这是一个简单的正则表达式程序。 实现了nfa到dfa、dfa最小化和自动机可视化。
要启用打印功能,可能需要安装graphviz
用法
from automaton_tools import DFA as MyDFA
myinput = "abc12.+qs{2,}(yui){1,2}?"
dfa = MyDFA.fromRegex(myinput)
# check whether the string matches the pattern from the beginning or not
ismatch = dfa.match("yuiyui")
# plot the transition graph
dfa.drawGraph("dfa")
# it will generate dfa.png file
已知错误
它无法正确处理.
或\w
。
因为他们被认为是一种特殊的角色。