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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:04:48+00:00 2026-05-31T06:04:48+00:00

Im trying to create a method that checks a string against a regular express

  • 0

Im trying to create a method that checks a string against a regular express and returns a register type(mips). The problem is that I can’t seem to be able to create the correct regex.
Please take a look and make suggestions. Thanks

 public static RegisterType CheckRegex(this string source)
        {
            var tempMatch = new Regex("$t0|$t1|$t2|$t3|$t4|$t5|$t6|$t7|$t8|$t9|").Match(source);  //$t0 - $t9
            if(tempMatch.Length == source.Length)
                return RegisterType.Temporary;
            var storeMatch = new Regex(@"(^\$s)+[0-9]").Match(source);  //$s0 - $s9
            if (storeMatch.Length == source.Length)
                return RegisterType.Store;
            var reservedMatch = new Regex(@"").Match(source);            //$k0 - $k1
            if (reservedMatch.Length == source.Length)
                return RegisterType.OSReserved;
            var constantMatch = new Regex(@"0-9").Match(source);        //Any integer
            if (constantMatch.Length == source.Length)
                return RegisterType.Constant;
            var memoryMatch = new Regex("").Match(source);
            if (memoryMatch.Length == source.Length)
                return RegisterType.Memory;

            return RegisterType.Invalid;
        }

UPDATE: Everything is working now ,excluding my Memory Regex

public static RegisterType GetRegisterType(this string source)
        {
            if (Regex.IsMatch(source, @"\$t[0-9]"))
                return RegisterType.Temporary; // $t0 - $t9
            if (Regex.IsMatch(source, @"\$s[0-9]"))
                return RegisterType.Store; // $s0 - $s9
            if (Regex.IsMatch(source, @"\$k[0-1]"))
                return RegisterType.OSReserved; // $k0 - $k1
            if (Regex.IsMatch(source, @"[-+]?\b\d+\b"))
                return RegisterType.Constant;
            if (Regex.IsMatch(source, @"\$zero"))
                return RegisterType.Special;
            if (Regex.IsMatch(source, @"[a-zA-Z0-9]+\b\:"))
                return RegisterType.Label;
            if (Regex.IsMatch(source, @"\d+\b\(\$[s-t]\b[0-9])"))
                return RegisterType.Memory;
            return RegisterType.Invalid;

        }
  • 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-31T06:04:49+00:00Added an answer on May 31, 2026 at 6:04 am

    As others have said, you need to escape the dollar signs in "$t0|$t1|$t2|$t3|$t4|$t5|$t6|$t7|$t8|$t9|" by prefixing them with a backslash. Also, you can write that more concisely as @"\$t[0-9]". That will match a dollar sign followed by 't' followed by a single digit. You’ve got a trailing pipe character followed by nothing, as well, that can be removed.

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

Sidebar

Related Questions

I am trying to create a bad word filter method that I can call
I'm trying to create a method which checks for a null/nil/empty string, and I'm
I am trying to create an extension method that i can forward a IList
Im trying to create a method that take 2 int array as the input
I'm trying to create a method that will sum two timeO objects and return
I am trying to create a method that accepts multiple types of controls -
I am trying to create a generic method that will read an attribute on
I am trying to create a unit test for a method that takes a
I'm trying to create a windowless Ogre application, but it seems that the method
I'm trying to create an application that will let me execute a method specified

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.