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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:52:48+00:00 2026-05-25T13:52:48+00:00

how can I create simple matrix for String that could be contains following combinations

  • 0

how can I create simple matrix for String that could be contains following combinations

123456 ABC    
123456AB1
123456AB12
123456AB123
123456

for example

if ("\\d + \\d + \\d + \\d + \\d + \\d  
   + \\s 
   + [a-zA-Z]+[a-zA-Z]+[a-zA-Z]") {
   //passed variant from input in form 123456 ABC

} else if ("\\d + \\d + \\d + \\d + \\d + \\d 
   + [a-zA-Z]+[a-zA-Z]+[a-zA-Z]
   + \\d") {
   //passed variant from input in form 123456AB1

} else if ("\\d + \\d + \\d + \\d + \\d + \\d 
   + [a-zA-Z]+[a-zA-Z]+[a-zA-Z]
   + \\d + \\d") {
   //passed variant from input in form 123456AB12

} else if ("\\d + \\d + \\d + \\d + \\d + \\d 
   + [a-zA-Z]+[a-zA-Z]+[a-zA-Z]
   + \\d + \\d + \\d") {
   //passed variant from input in form 123456AB123

} else if ("\\d + \\d + \\d + \\d + \\d + \\d") {
   //passed variant from input in form 0123456

} else {
   //doesn't match
}
  • 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-05-25T13:52:48+00:00Added an answer on May 25, 2026 at 1:52 pm

    You could for instance use the following regexs

    123456 ABC  -> \\d{6}\\s\\w{3}
    123456AB1   -> \\d{6}\\w{3}
    123456AB12  -> \\d{6}\\w{4}
    123456AB123 -> \\d{6}\\w{5}
    123456      -> \\d{6}
    

    The if-clauses can be used as in your example, e.g.,

    if(str.matches("\\d{6}\\s\\w+") { 
        ... 
    } ...
    

    Just as your question, these regex variants only covers the exact combinations from this example.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I create board for simple game, looks like for chess,but user could
I recently discovered that I can use lambdas to create simple event handlers. I
I'm looking for a way that I can create a simple modal window (or
How can I create a simple PHP file, which will retrieve the HTML and
Is there a pattern, Xml structure, architecture technique we can use to create simple
I want to create a simple menu function which can call it example get_menu()
I'm trying to create a simple custom validator for my project, and I can't
Suppose I create a very simple socket connection, how can one programatically: Find out
I am writing a simple Book create page in ASP.NET MVC. User can create
I was recently making a very simple application that just printed matrix-effect out to

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.