Skip to content

Instantly share code, notes, and snippets.

@alejio
Last active August 29, 2015 14:20
Show Gist options
  • Save alejio/8c6bcbc3412c5e700a3b to your computer and use it in GitHub Desktop.
Save alejio/8c6bcbc3412c5e700a3b to your computer and use it in GitHub Desktop.
Nanodegree > MongoDB > Lesson 4 > Problem set 1 > Omitting text in parentheses
def trim_par(line):
outp = []
comp=re.compile(r'\(+\S+\)', re.IGNORECASE)
linesplit=line.split()
for index in range(0, len(linesplit)):
m = comp.search(linesplit[index])
if m:
continue
else:
outp.append(linesplit[index]
outp=' '.join(outp)
return outp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment