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 8971701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:01:24+00:00 2026-06-15T18:01:24+00:00

Here i want to make regx for string which contains only 0 to 6

  • 0

Here i want to make regx for string which contains only 0 to 6 numbers only.
This String contains 0 to 6 numbers like that.

 Example-1 : "010002030405" Valid String

This String contains only o to 6 numbers so here i used this regx "[0-6]*". But one more thing i want to validate in this string, I want 0 only at odd positions 1-6 will not be on odd positions never. 0 can be place on odd and even both but 1-6 will be place only even positions.

Here i given u some valid and invalid string examples

Valid : 000102000004
invalid : 0023015006

Here i used this code Please suggest me or tell me what i have to change in my regx to satisfy below validation

1) String contains only 0-6 numbers nothing else.
2) 1-6 would be only even positions only they would not be at odd position ever, 0 would be odd and even position.

Code :

public boolean isOptions(String input) {
    String patternString = "[0-6]*";
    Pattern pattern = Pattern.compile(patternString);
    return pattern.matcher(input).matches();
}
  • 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-15T18:01:25+00:00Added an answer on June 15, 2026 at 6:01 pm

    Haven’t tried this out, but might work:

    (0[0-6])*0?
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my specific issue. I want to make an api level which then
![enter image description here][1] I want to make a tab layout application, in which
Small problem here I want to make a small fb app which show different
This question is built off of this previous question 'here' I want to make
Hi i want to make an feed reading application that it should look like
I'm referring to this link here: sortable I want to make these items inline,
i have this table in database which called data and i want make this
Here i want to make one file and write some data in this file
I want make a simple referral system. Basically referral URL structure something like this.
Please find the code at http://jsfiddle.net/wlogeshwaran/NGL8P/4/ Here i want to make the 'hi' ,

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.