开发者

Matching a binary string with 3 or more occurrences of '1'. Can this regex be improved?

开发者 https://www.devze.com 2023-01-10 06:31 出处:网络
^[0-1]*1[0-1]*1开发者_如何学编程[0-1]*1[0-1]*$ To match a binary string with 3 or more occurrences of \'1\'
^[0-1]*1[0-1]*1开发者_如何学编程[0-1]*1[0-1]*$

To match a binary string with 3 or more occurrences of '1' This expression works...just trying to make it better.


To match three or more occurrences of 1, I would use:

^(0*1){3}[01]*$


i think it'll be something like this, edited changed with alans suggestions

^(0*1){3,}0*$
0

精彩评论

暂无评论...
验证码 换一张
取 消