DB<100> $str = q!AND (random text) AND (more random text) AND (yet more)!; => "AND (random text) AND (more random text) AND (yet more)" DB<101> print "$1: $2\n" while $str =~ /(AND|OR)(.+?)(?=AND|OR|$)/g AND: (random text) AND: (more random text) AND: (yet more)