mardi 3 novembre 2015

C# Check if contains various combination of substring

I want to check If my OCR result (a string) is either "No Edge" or "No Signal".

Problem is sometimes I would get N0 Edge, No Signa1, N0 signa1, No 5ignal, etc. The letter o, S, i and l can sometimes become digits or something else. Unfortunately there is nothing else I can do regarding the OCR.

Currently I am doing this:

ocrResult = ocrResult.ToLower();
if (ocrResult.Contains("edg") || ocrResult.Contains("gna"))
{
    //no edge or no signal
}

else
{
    //Not no edge or no signal
}

Can any of you please suggest a smarter approach?

Aucun commentaire:

Enregistrer un commentaire