Python | Extract Numbers in Brackets in String
Sometimes, while working with Python strings, we can have a problem in which we have to perform the task of extracting numbers in string that are enclosed in brackets. Lets discuss certain way in which this task can be performed.
Method : Using regex
The way to solve this task is to construct a regex string that can return in all the numbers in a string that have brackets around them.
The original string is : gfg is   all geeks Extracted number list : ['1', '4']