In my Python code, I have something like this:
Type1 = [re.compile("-" + d + "-") for d in "49 48 29 ai au2".split(' ')]
Type2 = [re.compile("-" + d + "-") for d in "ki[0-9] 29 ra9".split(' ')]
Everything = {"Type1": Type1, Type2: Type2}
And a small function to return the type of the input string.
def getInputType(input):
d = "NULL"
input = input.lower()
try:
for type in Everything:
for type_d in Everything[type]:
code = "-" + input.split('-')[1] + "-"
if type_d.findall(code):
return type
except:
return d
return d
Is there a one-line equivalent of defining these multiple regexes in C# or should I have to resort to declaring each of them separately? In short, what is a good way of converting this to C#?
I think a fairly straightforward translation would be: