I am trying to use this regular expression to remove all instances of square brackets (and everything in them) from strings. For example, this works when there is only one p
For Numbers inside the brackets (No Alphabets), e.g. [89], [23], [11], etc., this is the pattern to use.
import re
text = "The[TEXT] rain in[33] Spain[TEXT] falls[12] mainly in[23] the plain![45]"
pattern = "\[\d*?\]"
numBrackets = re.findall(pattern, text)
print(numBrackets)
Output:
['[33]', '[12]', '[23]', '[45]']