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

  • Home
  • SEARCH
  • 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 6796377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:27:37+00:00 2026-05-26T18:27:37+00:00

I have many different formats of input strings, and I need to split the

  • 0

I have many different formats of input strings, and I need to split the input string into 3 sections. A few examples below (although there are several possibilities):

1A1 = 1, A, 1

123AA44 = 123, AA, 44

AA44 = empty, AA, 44

44AA = 44, AA, empty

Additional constraints for these sections:

  • 1st section is only numeric and is 1-4 characters long
  • 2nd section is only alpha and is 1-3 characters long
  • 3rd section can be numeric or alpha-numeric and is 1-4 characters long

I have reached the end of my regex knowledge with the code below. It works for every scenario except when one of the 3 sections is left empty in the input. Need some help! Thanks.

Regex regex = new Regex("(?<Section1>[0-9]{1,4})(?<Section2>[a-zA-Z]{1,3})(?<Section3>[0-9a-zA-Z]{1,4})");
Match match = regex.Match(inputString);

string 1 = match.Groups["Section1"].Value;
string 2 = match.Groups["Section2"].Value;
string 3 = match.Groups["Section3"].Value;
  • 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-26T18:27:37+00:00Added an answer on May 26, 2026 at 6:27 pm

    Did you try this?

    Regex regex = new Regex("(?<Section1>[0-9]{0,4})(?<Section2>[a-zA-Z]{0,3})(?<Section3>[0-9a-zA-Z]{1,4})");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many different small classes which have a few fields each, e.g. this:
E.g. i might have input string like below: 2012-07-23T03:30:00.000Z or 2012-06-25T13:00:00.000+08:00 For these two
I have many different NSArray 's stored in .dat files, in the Documents folder
In my application I have many different JSP forms with multiple stages, that is
I have looked at many different peoples answers to this problem but they only
I want to submit a form that have many checkboxes with different values, using
I have an application with many different parts, it runs on OSGi, so there's
I have many tables with identical schemas but different names. Can I create a
i have hundreds of [mostly different] files in many different directories that all have
I have many layers in the Documents that will be displayed on different user

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.