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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:09:51+00:00 2026-05-27T22:09:51+00:00

Looking for either a solution, some ideas or being point in the right direction

  • 0

Looking for either a solution, some ideas or being point in the right direction on how to resolve a problem.

Basically, I have to figure out if a string value is in between a Low and High string value. However, the values are in a format which String.Compare will not work. But, a human can easily figure out.

For example, one of my ranges is Low: A7, High A12. A8 fits in between those values but String.Compare says it does not. A13 would not fit between the values.

Other examples of Low and High values are:

Low Value – High Value

1A1 – 1A12

25W00 – 25W050

42W1 – 42W296

W232N0002 – W232N000598

In the above examples 1A2 would fit between the Low High Value of 1A1 and 1A12, but 1A100 would not.

Any ideas on how to resolve this? I know this had to have been encountered before.

  • 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-27T22:09:52+00:00Added an answer on May 27, 2026 at 10:09 pm

    This could use some optimization, but it’s a proof of concept.
    Just convert the letters to numerical values and compare the results:

    private bool ValueIsBetween(string value, string lowValue, string highValue)
    {
        long low = long.Parse(ConvertToNumber(lowValue));
        long high = long.Parse(ConvertToNumber(highValue));
        long val = long.Parse(ConvertToNumber(value));
        return val > low && val < high;
    }
    
    private string ConvertToNumber(string value)
    {
        value = value.ToUpper();
        value = value.Replace("A", "0");
        value = value.Replace("B", "1");
        value = value.Replace("C", "2");
        value = value.Replace("D", "3");
        value = value.Replace("E", "4");
        value = value.Replace("F", "5");
        value = value.Replace("G", "6");
        value = value.Replace("H", "7");
        value = value.Replace("I", "8");
        value = value.Replace("J", "9");
        value = value.Replace("K", "10");
        value = value.Replace("L", "11");
        value = value.Replace("M", "12");
        value = value.Replace("N", "13");
        value = value.Replace("O", "14");
        value = value.Replace("P", "15");
        value = value.Replace("Q", "16");
        value = value.Replace("R", "17");
        value = value.Replace("S", "18");
        value = value.Replace("T", "19");
        value = value.Replace("U", "20");
        value = value.Replace("V", "21");
        value = value.Replace("W", "22");
        value = value.Replace("X", "23");
        value = value.Replace("Y", "24");
        value = value.Replace("Z", "25");
    
        return value;
    }
    

    Results:

    ValueIsBetween("1A2", "1A1", "1A12");
    

    true

    ValueIsBetween("1A100", "1A1", "1A12");
    

    false

    ValueIsBetween("43W4", "42W1", "44W3");
    

    true

    Edit:
    Try this improved algorithm instead:

    private bool ValueIsBetween(string value, string lowValue, string highValue)
    {
        return !ValueIsLessThan(value, lowValue) && ValueIsLessThan(value, highValue);
    }
    
    private bool ValueIsLessThan(string value, string compareTo)
    {
        var matches = Regex.Matches(value, "[0-9]+|[a-zA-Z]+");
        var matchesB = Regex.Matches(compareTo, "[0-9]+|[a-zA-Z]+");
    
        var count = matches.Count < matchesB.Count ? matches.Count : matchesB.Count;
    
        for (int i = 0; i < count; i++)
        {
            long val;
            long val2;
            if (long.TryParse(matches[i].Value, out val))
            {
                if (long.TryParse(matchesB[i].Value, out val2))
                {
                    if (val > val2) return false;
                    if (val < val2) return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                if (matches[i].Value.CompareTo(matchesB[i].Value) > 0 ) return false;
                if (matches[i].Value.CompareTo(matchesB[i].Value) < 0 ) return true;
            }
        }
    
        return true;
    }
    

    Results:

    ValueIsBetween("B431Z543", "A0", "Z9");
    

    true

    ValueIsBetween("4B31Z543", "A0", "Z9");
    

    false

    ValueIsBetween("1A2", "1A1", "1A12");
    

    true

    ValueIsBetween("1A100", "1A1", "1A12");
    

    false

    ValueIsBetween("43W4", "42W1", "44W3");
    

    true

    ValueIsBetween("W5", "CC4", "CC6");
    

    false

    ValueIsBetween("W8B4", "W5C3", "W7C3");
    

    false

    ValueIsBetween("W5C4", "W5C3", "C7W3"); 
    

    false

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

Sidebar

Related Questions

I’m looking for some samples/tutorials/general pointers in doing either of the following. 1) Create
I have been looking for a solution, and haven't been lucky to find one.
I'm needing some help with mod rewriting. I have been looking online for the
I'm looking for a solution for this problem in C or C++. edit :
I'm trying to come up with a simple solution to a problem I have
I am looking for either a FireFox extension, or a similar program, that allows
I am looking for either a NAnt Task for SQL Server bcp, or the
Looking to implement a RIA (rich internet application) either as a java (JWS) application
I am looking for a command line either for an algorithm (script) which allows
I am looking for an effective way to either clone/rename or re-create address fields

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.