Regex: Binary string contains at least 3 of a certain integer

Luke

I am working with regular expressions for a class and we need to have it set up to contain at least 3 0 throughout the string. BUT they don't need to be next to each other, so 101010 would pass but 101011 would fail because it lacks a 0. ^[0-1]*(?:0){3,}[0-1]*$ This is what I currently have but that requires them to be adjacent.

Jim Simson

How about:

([01]*0[01]*){3}

The 0 in the center without a qualifier ensures that it exists at least 3 times in your string. The [01]* on either side requires a 0 or 1 zero to unlimited times, giving it some wiggle room so as not to require that the 3 zeros occur consecutively. (Demo) (regexr.com)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Regex to match a string that contains at least 3 dashes / hyphens

Most efficient regex for checking if a string contains at least 3 alphanumeric characters

java regex contains certain string

Regex to determine if string contains at least 2 numbers

Regex: Match if link contains certain string only

Regex - string contains after certain character

Regex: capture sentence if string contains certain patterns

Regex for string starting with $ followed by integer and contains brackets

PHP (Regex) Check if a string contains at least 4 digits + 2 letters

Regex: how to know that string contains at least 2 upper case letters?

Regex: string contains at least one set of curly brackets

Javascript regex: check if a string is alphanumeric AND it contains a letter (at least)

Javascript regex to check for at least 3 carets in a string

Check if array-list contains a certain string and integer

Regex - Match a certain string and get the integer value of the string

Regex To Match String With All Words Contains Certain Format

How to filter out results contains certain string in vim regex?

Regex contains at least one uppercase letter AND NOT contains at least one underscore

Pandas: How return all rows if column string contains at least a certain number of strings from a list?

String contains at least one digit

Regex: match at least 3 characters in a string in specific order

RegEx to make sure that the string contains at least one lower case char, upper case char, digit and symbol

How do I search if a string contains at least one word from a list using regex?

Converting a binary string to integer

Binary String to Integer Stack

string in binary format to integer

Regex: Find those html tags which contains at least 3 of some keywords

Regex to match a email to contains at least one character

Regex for string contains?