Actually, both regular expression and isdigit() method are good at their own place but I would suggest you use isdigit()but if you are not comfortable writing complex regular expression’s code then you should go for isdigit() method. Here’s an explanation of how regular expression and isdigit() method works:-
The reason why you should use isdigit():-
The first reason is you need not to import any extra module for using isdigit() method.
The second reason is regular expression is more complex while writing the code.
Last but not the least isdigit() looks more Pythonic then regular expression.
How regular expression works:-
re.findall(r'\d+', 'hello 12 hi 89')
How the isdigit() method works:-
str = "hello 12 hi 89"
[int(s) for s in str.split() if s.isdigit()]