I am trying to find the minimum pattern in string examples (2 char):
enter code here #!/usr/bin/perl use warnings; use strict; my $str1; $str1 = 'abbabbabbabbabb'; # abb is repeating $str1 = 'abababababababa'; # ab is repeating $str1 = 'abaaaabaaaabaaa'; # abaaa is repeating $str1 = 'bbaabbaabbaabbaa'; # bbaa is repeating
it is always 2 characters 'a' and 'b', and there is always a pattern, there are no angular cases of “a” or “b”. any help is appreciated.
thanks michael
my ($repeated_pattern) = $str1 =~ /^(.+?)\1+\z/s;
Source: https://habr.com/ru/post/1481444/More articles:Legend using PathCollections in matplotlib - pythondyld: unknown boot command 0x80000022 error installing Git - gitScanner line error - javaJQuery effect makes element move during animation - jqueryExporting a Vector Image Illustrator from PDF Using C # - c #Very slow assignment to a vector with an unnamed (name) in R - performanceUsing the presence of an indexer as a parameter of a signature / contract / type parameter - c #Dependencies not loading or partially loading - vb.netIs JavaScript “not a function” compared to the “expected function”? - javascriptJavaScript Error "Function Expected" - javascriptAll Articles