import re
cRegEx = re.compile('\[[0-9]*\]')
text = 'in a deliberate challenge to the social order[14]'
def remove_citations(text):
return re.sub(cRegEx, '' , text)
print(remove_citations(text))
pText = 'example of if condition if(flag)'
pRegEx = re.compile('\(.*\)')
def remove_parentheses(pText):
return re.sub(pRegEx, '', pText)
print(remove_parentheses(pText))
Posted inPython