example_line = 'jkhasdkjashdasjkd|abbbabbababcbccc'
bad_chars = {'a', 'b', 'c'}
re.sub('[%s]+$' % ''.join(bad_chars), '', example_line)
Remove final characters from string recursively - What's the best way to do this?