Multiple regex matches to correct OCR output Using OCR, my program reads the current selection for each of these categories: format, invert color? and storage. The OCR result will always have inconsistent error here and there, which is why I need a Regex match and return the correct wording for each selection:        

//format
private Regex bmp8 = new Regex(".bmp.8....");
private Regex bmp24 = new Regex(".bmp.24....");
private Regex png24 = new Regex(".png.24....");
private Regex raw = new Regex("raw");
private Regex ts = new Regex("....setup");
private Regex csv = new Regex(".csvd...");

//invert color?
private Regex yes = new Regex("y.s");
private Regex no = new Regex("n.");

//storage
private Regex intrnl = new Regex(".nte...");
private Regex erase = new Regex("e.ase");
private Regex transfer = new Regex("t.ansf.");
private Regex usbdev = new Regex("usbdev.");

private string CheckStorage(string input)
{
    if (intrnl.IsMatch(input))
    {
        return "Internal";
    }

    else if (erase.IsMatch(input))
    {
        return "Erase";
    }

    else if (transfer.IsMatch(input))
    {
        return "Transfer";
    }

    else
    {
        return "USB Device";
    }
}

private string CheckInvertColor(string input)
{
    if (yes.IsMatch(input))
    {
        return "Yes";
    }

    else
    {
        return "No";
    }
}

private string CheckFormat(string input)
{
    if (bmp8.IsMatch(input))
    {
        return "bmp(8-bit)";
    }

    else if (bmp24.IsMatch(input))
    {
        return "bmp(24-bit)";
    }

    else if (png24.IsMatch(input))
    {
        return "png(24-bit)";
    }

    else if (raw.IsMatch(input))
    {
        return "Raw";
    }

    else if (ts.IsMatch(input))
    {
        return "Trace &amp; Setup";
    }

    else
    {
        return "csv Data";
    }
}


I am sure there is a better way to tidy up this code, perhaps using List&lt;&gt;?
I see something that bugs me in your code, that being default return values and some unused regex expressions declared, for example in the following function:

private string CheckInvertColor(string input)
{
    if (yes.IsMatch(input))
    {
        return "Yes";
    }

    else
    {
        return "No";
    }
}


Why do you only check if the yes regex is a match, what if the input is different from the one that matches the no answer? What do you expect the code to do in this case? You return a "No" in any case that the yes regex does not match, then why have the no regex declared at all?

This also applies to the "USB device" and "csv data" of their respecting functions, you are not actually checking those values yet have them declared still.

I stress this because in my opinion, you should prevent unexpected inputs from returning a value for which you are expecting a specific input for. Instead the code should throw an exception or a value which then you can manage elsewhere to notify that an unexpected input has been fed to the function.

In regards to tiding up your code, there are some options you can use but the one that suits your needs is the following one:

Dictionaris 

Although you may already know, a dictionary is a class that returns a value if the key supplied exists in said dictionary, with it your regex declarations would look like in the following:

private Dictionary&lt;Regex, string&gt; formatDictionary = new Dictionary&lt;Regex, string&gt;()
{
    {new Regex(".bmp.8...."),"bmp(8-bit)"},
    {new Regex(".bmp.24...."),"bmp(24-bit)"},
    {new Regex(".png.24...."),"png(24-bit)"},
    {new Regex("raw"),"Raw"},
    {new Regex("....setup"),"Trace &amp; setup"},
    {new Regex(".csvd...."),"csv data"},
}

private Dictionary&lt;Regex, string&gt; inversionDictionary = new Dictionary&lt;Regex, string&gt;()
{
    {new Regex("y.s"),"Yes"},
    {new Regex("n."),"No"}
}

private Dictionary&lt;Regex, string&gt; storageDictionary = new Dictionary&lt;Regex, string&gt;()
{
    {new Regex(".nte..."),"Internal"},
    {new Regex("e.ase"),"Erase"},
    {new Regex("t.ansf."),"Transfer"},
    {new Regex("usbdev."),"USB Device"}
}


This way, with a LINQ query, you can check the validity of the input:

if (!storageDictionary.Any(x =&gt; x.Key.IsMatch(input)))
    throw new Exception("the input is not valid");


This way you can ensure that the input matches at least one of the Regex you defined, now you can recover the corresponding value:

return storageDictionary[storageDictionary.Where(x =&gt; x.Key.IsMatch(input)).First().Key];


Your functions would end up looking like this:

private string CheckInvertColor(string input)
{
    if (!storageDictionary.Any(x =&gt; x.Key.IsMatch(input)))
        throw new Exception("the input is not valid");

    return storageDictionary[storageDictionary.Where(x =&gt; x.Key.IsMatch(input)).First().Key];
}