I have a situation where I have to exclude an ever growing list of conditions in an if statement that started out rather simple
I've thought of looping an list/array and I use RegEx when possible.
I would just like to know what others have done to try and simplify these situations.
here's a quick example:
if (!DataField.Contains(strText) & (strOtherText.IndexOf(strFindThis) < 0) || Regex.isMatch(strWithLetters, @"[A-Z]"))
{
//Do things;
}
else
{
//Do Other Things;
}
Still learning the RegEx but I'm working on it
So far it's been strings of several words or simply certain characters.
For example:
- "#, &, ^, @, and more.."
- "Form 9999-99 invalid client name"
- Can't start with "https" or "http"
- In some case if it contains a string like "Error Code" then it would be saved in an alternate file instead of simply being ignored for processing
I have 23 of these so far