Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8949041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:08:47+00:00 2026-06-15T13:08:47+00:00

Write a regular expression that describes all strings of zeroes and ones representing binary

  • 0

“Write a regular expression that describes all strings of zeroes and ones representing binary numbers that are either odd or divisible by 8. The numbers may not have any leading zeros.”

I gave my answer as (000|1)$ which was marked wrong. I cannot see the reason why. Please explain! Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T13:08:48+00:00Added an answer on June 15, 2026 at 1:08 pm

    You forgot two of the requirements.

    1. It must contain only 1s and 0s:

      ^[01]*(000|1)$
      
    2. There may be no leading 0s:

      ^(?!0)[01]*(000|1)$
      

      If lookaheads are not allowed, it becomes a bit trickier:

      ^1[01]*(000|1)$|^1$
      

    Another addition, if you are allowed to use only the regular expression constructs that are available in “theoretical” regular expressions (alternation, group and repetition), it would look like this (anchors are implicit in this case):

    1(0|1)*(000|1)|1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How does one write a regular expression in java that will match all strings
How to write a regular expression that will pass a numbers from 60 to
How do I write a regular expression that will match all words starting with
I am trying to write a regular expression that can extract (possibly multiple) strings
I want to write a regular expression in F# that represents strings which start
I need to write a regular expression that matches with 3 slightly different strings
How to write a regular expression in javascript that must follow the conditions All
I am trying to write a Regular Expression that replaces all the digits of
How would you write a regular expression that will return all words that contain
I'm trying to write a regular expression that matches strings like these: title(Hello+World) #=>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.