... my @arr = $string =~ / [^KR]+ # collect non K|R . # the following must be K|R (?!P) # ignore if fragment would start by P /gsx; ...