Hi everyone.
I hope you can give me a hand with this:
I have a list of tuples like this:
table = [
("aaa", "a","b", 0),
("aaa", "a", "c", 1),
("aaa", "b", "a", 2),
("aaa", "b", "c", 3),
("aaa", "c", "a", 4),
("aaa", "c", "b", 5),
("aaa", "a", "*", 6),
("aaa", "b", "*", 7),
("aaa", "c", "*", 8),
...
]
More less like that. I't huge.
Now, the * means one digit.
So, as you can see, this table holds some kind of (not so)regular expressions
The idea is that if you write "aaa a b" you get 0. If you write "aaa c 1" you get 8.
The program actually works. But i want to change it to use python regular expressions.
I managed to write the regular expressions to match the strings and keep it in groups:
r'(?P<matcha>aaa[\s]+(a|b|c)[\s]+(a|b|c|[\d]))'
This, matches all the tuples in the example table.
My question.
Is there a way to get an specific integer from a match(like the one in the table)
Or maybe translate the match into the "table-regular-expression-format".