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']
- Python | Extract substrings between brackets
- Python | Extract numbers from string
- Python | Remove square brackets from list
- Python - Matching Pairs of Brackets
- Python | Extract numbers from list of strings
- Extract numbers from a text file and add them using Python
- Python Regex to extract maximum numeric value from a string
- Python | Extract words from given string
- Python | Extract only characters from given string
- Python | Extract digits from given string
- Python | Extract length of longest string in list
- Python | Extract Score list of String
- Python | Extract odd length words in String
- Python | Extract characters except of K string
- Python - Extract String till Numeric
- Python - Extract words starting with K in String List
- Python - Extract Percentages from String
- Python - Extract range characters from String
- Python | Extract key-value of dictionary in variables
- numpy.extract() in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.