I have the following code ...
tablesInDataset = ["henry_jones_12345678", "henry_jones", "henry_jones_123"]
for table in tablesInDataset:
tableregex = re.compile("\d{8}")
tablespec = re.match(tableregex, table)
everythingbeforedigits = tablespec.group(0)
digits = tablespec.group(1)
My regex should only return a string if it contains 8 digits after the underscore. When it returns the string, I want to use .match()to get two groups using the method .group(). The first group must contain a string that will contain all the characters before the digits, and the second should contain a string with 8 digits.
Can someone please help me figure out the right regex to use the results I'm looking for using .match()and .group()?