普通防爆pression由5整除二进制数 [英] Regular Expression for Binary Numbers Divisible by 5

查看:316
本文介绍了普通防爆pression由5整除二进制数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过5.结果编写可分二进制数经常EX pression
我已经做了常规的前$ P $为能被2整除二进制数和3 pssions,但我无法找到一个5。

有什么建议?


解决方案

 (0 | 1(10)*(0 | 11)(01 * 01 | 01 * 00(10) *(0 | 11))* 1)*

添加 ^ $ 用正则表达式进行测试。 看它这里工作。



你可以建立一个 DFA 并把它转换为普通EX pression。在DFA已经建成另一个答案。你可以阅读它,它是很好的解释。


总的想法是,以删除节点,增加边。

变成了:

后



利用这一概念,并从我挂了答案的FDS,这里有获得正规前pression步骤:




I want to write a regular expression for Binary Numbers Divisible by 5.
I have already done the regular expressions for Binary Numbers Divisible by 2 and for 3 but I couldn't find one for 5.

Any suggestions?

解决方案

(0|1(10)*(0|11)(01*01|01*00(10)*(0|11))*1)*

Add ^$ to test it with regexp. See it working here.


You can build a DFA and convert it to regular expression. The DFA was already built in another answer. You can read it, it is very well explained.
The general idea is to remove nodes, adding edges.

Becomes:


Using that concept and the FDS from the answer I linked, here are the steps to get the regular expression:

这篇关于普通防爆pression由5整除二进制数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆