use strict; use warnings; #we have no plan! #usually want to pick and choose tests anyway #so the number is not fixed use Test::More qw(no_plan); #============================================================ # VARIOUS EXPERIEMENTS #============================================================ #--------------------------------------------------- #GOAL: find run of repeating letters #--------------------------------------------------- sub regexRepeat { my ($sInput, $sOutput) = @_; #----------------------------------------- # add tests here to try out different things # if it doesn't work, change is to isnt #------------------------------------------ #changed is to isnt: #this doesn't work, $input='abcdeee' results in 'ab' isnt(eval {$sInput =~ /(..)/;$1}, $sOutput , q{using /(..)/}); #changed is to isnt: #$input='abcdeee' printed out only 'e' isnt(eval {$sInput =~ /(.)\1/;$1}, $sOutput , q{using /(.)\1/}); #changed is to isnt: #$input='abcdeee' printed out undef isnt(eval {$sInput =~ /((.)\1)/;$2}, $sOutput , q{using /((.)\1)/;$2}); #changed is to isnt: #$input='abcdee' also printed out undef isnt(eval {$sInput =~ /((.)\1)/;$1}, $sOutput , q{using /((.)\1)/;$1}); #BINGO! this worked is(eval {$sInput =~ /(.)(\1+)/;"$1$2"}, $sOutput , q{using /(.)(\1+)/;"$1$2"}); } #============================================================ # HERE IS WHERE I SELECT EXPERIMENTS #============================================================ regexRepeat('abcdeeef', 'eee'); #only one to find regexRepeat('abbb;eeef', 'bbb'); #should find first