/
ilya.petrash
/
SimplePyScripts
Обзор
Документация
Войти
/
ilya.petrash
/
SimplePyScripts
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
regexp_examples/find_longest__seq_sub.py
16 строк
338 B
gil9red
Refactoring. Using black code style
14 июн 2023, 12:20
14 июн 2023, 12:20
a869168
Код
Авторство
О чём код?
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = "ipetrash" import re def find_longest(s): return max(re.findall(r"((\w+?)\2+)", s), key=lambda t: t[0].count(t[1])) if __name__ == "__main__": text = "helloworld world world hellohellohelloworldworld" print(find_longest(text)) # ('hellohellohello', 'hello')