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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T13:34:49+00:00 2026-05-10T13:34:49+00:00

I am attempting to parse a string like the following using a .NET regular

  • 0

I am attempting to parse a string like the following using a .NET regular expression:

H3Y5NC8E-TGA5B6SB-2NVAQ4E0 

and return the following using Split: H3Y5NC8E TGA5B6SB 2NVAQ4E0

I validate each character against a specific character set (note that the letters ‘I’, ‘O’, ‘U’ & ‘W’ are absent), so using string.Split is not an option. The number of characters in each group can vary and the number of groups can also vary. I am using the following expression:

([ABCDEFGHJKLMNPQRSTVXYZ0123456789]{8}-?){3} 

This will match exactly 3 groups of 8 characters each. Any more or less will fail the match. This works insofar as it correctly matches the input. However, when I use the Split method to extract each character group, I just get the final group. RegexBuddy complains that I have repeated the capturing group itself and that I should put a capture group around the repeated group. However, none of my attempts to do this achieve the desired result. I have been trying expressions like this:

(([ABCDEFGHJKLMNPQRSTVXYZ0123456789]{8})-?){4} 

But this does not work.

Since I generate the regex in code, I could just expand it out by the number of groups, but I was hoping for a more elegant solution.


Please note that the character set does not include the entire alphabet. It is part of a product activation system. As such, any characters that can be accidentally interpreted as numbers or other characters are removed. e.g. The letters ‘I’, ‘O’, ‘U’ & ‘W’ are not in the character set.

The hyphens are optional since a user does not need top type them in, but they can be there if the user as done a copy & paste.

  • 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. 2026-05-10T13:34:50+00:00Added an answer on May 10, 2026 at 1:34 pm

    I have discovered the answer I was after. Here is my working code:

        static void Main(string[] args)     {         string pattern = @'^\s*((?<group>[ABCDEFGHJKLMNPQRSTVXYZ0123456789]{8})-?){3}\s*$';         string input = 'H3Y5NC8E-TGA5B6SB-2NVAQ4E0';         Regex re = new Regex(pattern);         Match m = re.Match(input);          if (m.Success)             foreach (Capture c in m.Groups['group'].Captures)                 Console.WriteLine(c.Value);     } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 207k
  • Answers 207k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer When using SimpleXML, you should always name your variables after… May 12, 2026 at 9:16 pm
  • Editorial Team
    Editorial Team added an answer Better compare it to C (or C++ or D). As… May 12, 2026 at 9:16 pm
  • Editorial Team
    Editorial Team added an answer You really need to get some query plans, and edit… May 12, 2026 at 9:16 pm

Related Questions

I am attempting to parse a string in Perl with the format: Messages pushed
I would like to authenticate username and passwords for my application on a windows
I am attempting to use the HtmlAgilityPack library to parse some links in a
I am attempting to use JSON to send data between the browser and my

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.