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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:21:02+00:00 2026-05-28T03:21:02+00:00

I have an ASP.NET application written in C# (3.5 framework) where users have provided

  • 0

I have an ASP.NET application written in C# (3.5 framework) where users have provided me with a list of patterns that we have put rules around. I could write code to manually account for each pattern, but would prefer to find a way to use regular expressions (or any method really) to handle them so I can allow the users to create more patterns (following some guidelines of course) in the future.

I will do my best to show exactly what it is I am trying to do. I really appreciate your help.

Here are a few of the patterns:

Pattern 1:
Element 1: CxxxxRxxxx
Element 2: CxxxxRzzzz
Result: Bucket 1

Pattern 2:
Element 1: CxxxxRxxxx
Element 2: CxxxxRxxxx
Result: Bucket 2

Pattern 3:
Element 1: PCxxxxxxxx
Element 2: PCzzzzzzzz
Result: Bucket 3

Pattern 4:
Element 1: PCxxxxxxxx
Element 2: UxxxxRxxxx
Result: Bucket 4

Here’s what they mean and how I need to handle them. For starters, all the elements are always 10 characters in length. The alphabetical characters are constant for each pattern. The X’s and Z’s can be numbers or letters. What the X’s and Z’s signify in the pattern is whether the other parts of the 2 elements match each other.

For instance, my input data is “C1234R5678” as element 1 and “C1234R9999” for element 2. In this case, the result would be “Bucket 1” since this matches the pattern defined for this condition (the numbers after the “C” match, but the numbers after the “R” do not).

In another example, my input data is “C1234R5678” as element 1 and “C1234R5678” for element 2. In this case, the result would be “Bucket 2” since this matches the pattern defined for this condition (the numbers after the “C” match, and the numbers after the “R” match as well).

In another example, my input data is “PC12345678” as element 1 and “PC87654321” for element 2. In this case, the result would be “Bucket 3” since this matches the pattern defined for this condition (the numbers after the “PC” do not match).

In a final example, my input data is “PC12345678” as element 1 and “U1234R5678” for element 2. In this case, the result would be “Bucket 4” since this matches the pattern defined for this condition (the 4 numbers after the “PC” match the 4 numbers after the U and the last 4 digits of the PC element match the 4 digits after the R of element 2).

As you can see, the patterns can be different in that sometime you are identifying 4 numbers after a letter or a whole run of numbers after a letter.

Thanks for your time.

  • 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-28T03:21:02+00:00Added an answer on May 28, 2026 at 3:21 am

    You can do something like:

    For each (Element1,Element2) pair:
        match Element1,Element2 on "(x+|z+)" -> matches1,matches2
    
        for (i=0;i<min(matches1,matches2);i++) {
            replace 'x+' by '([A-Za-z0-9]{matches1[i].Length})'
            // note: need the brackets here to act as capturing brackets
            // so that backreferences can be used!
    
            if matches2[i] is 'xxxxx':
                replace 'x+' by '(?!\i)[A-Za-z0--9]{matches2[i].Length}'
            else if matches2[i] is 'zzzzz':
                replace 'z+' by '\i'
        }
        Then replace miscellaneous leftover 'xxxx' by '[A-Za-z0-9]{lengthofmatch}'.
    
        Then join the new Element1 and Element2 by a delimiter e.g. '-'
    

    This will construct a bunch of strings like:

    //Pattern 1
    C([A-Za-z0-9]{4})R([A-Za-z0-9]{4})-C(?!\1)[A-Za-z0-9]{4}R\2
    //Pattern 2
    C([A-Za-z0-9]{4})R([A-Za-z0-9]{4})-C(?!\1)[A-Za-z0-9]{4}R(?!\2)[A-Za-z0-9]{4}
    //Pattern 3
    PC([A-Za-z0-9]{8})-PC\1
    //Pattern 4
    PC([A-Za-z0-9]{8})-U(?!\1)[A-Za-z0-9]{4}R[A-Za-z0-9]{4}
    

    Then for each input data append Element1 and Element2 separated by a ‘-‘ (e.g. "C1234R5678-C1234R9999") and match against each pattern, and stop at the first match.

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

Sidebar

Related Questions

I have this code in my ASP.NET application written in C# that is trying
I have a ASP.NET application that we've written our own logging module for. My
I have an application that was written in vanilla ASP.NET that I would like
I have an ASP.NET MVC 3 (using Entity Framework 4.2) application that uses transactions
I have an ASP.NET (C#) application, written with VS 2008, that uses CodeBehind files
I have written a small Asp.net application using Entity Framework. A Stored Procedure accepts
We have an enterprise application written in asp.net c# (3.5) and SQL server that
I have been reviewing an asp.net application that was written by a former colleague.
I have written an ASP.NET MVC application that allows the user to specify their
I have to deal with legacy ASP.NET application written in .NET Framework 1.1. When

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.