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
Try:
import re pattern = r'\[[^\]]*\]' s = """Issachar is a rawboned[a] donkey lying down among the sheep pens.[b]""" t = re.sub(pattern, '', s) print t
Output:
Issachar is a rawboned donkey lying down among the sheep pens.