Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
PCRE2 (PHP >=7.3)

/
(?=((.+?)\2+))
/
gm

Description

in this one you should find a repeating sequence inside the substring. I have an example for you: in a string "abababc" - "ab" is a sequence that repeats more than once, so the answer will be "ababab" repeat_inside('aaaaa') == 'aaaaa' repeat_inside('aabbff') == 'aa' repeat_inside('aababcc') == 'abab' repeat_inside('abc') == '' repeat_inside('abcabcabab') == 'abcabc'

Submitted by https://py.checkio.org/mission/long-repeat-inside/publications/rossras/python-3/regular-expressions-now-you-have-two-problems/ - 3 years ago (Last modified 3 years ago)