import re str_to_search = 'abababsonab, etc'second = re.search(r'(?:.(?!son))+', str_to_search)print(second.group())
Standard input is empty
ababa
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!