fork download
  1. import re
  2. text = [
  3. "this is a figure ref (figure 7\xe2\x80\x9377)",
  4. "this is multiple refs (figures 6\xe2\x80\x9328 and 6\xe2\x80\x9329)",
  5. "this is a table ref (table 6\xe2\x80\x931)"
  6. ]
  7. text = [re.sub(r'\s*\(\s*(?:table|figure)[^()]*\)', '', t) for t in text]
  8. print(text)
Success #stdin #stdout 0.02s 9640KB
stdin
Standard input is empty
stdout
['this is a figure ref', 'this is multiple refs', 'this is a table ref']