$str = q!AND (random text) AND (more random text) AND (yet more)!; $str = q!OR (random text) OR (more random text) OR (yet more)!; #### while ($str =~ /\G(AND|OR)\s+(.+?)/g) { printf("%s %s\n", $1, $2); } #### while ($str =~ /\G(AND|OR)\s+(\(.+?\))/g) { printf("%s %s\n", $1, $2); } #### $str = q!AND (random text) AND (yet (more))!;
## while ($str =~ /\G(AND|OR)\s+(.+?)/g) { printf("%s %s\n", $1, $2); } ##
## while ($str =~ /\G(AND|OR)\s+(\(.+?\))/g) { printf("%s %s\n", $1, $2); } ##
## $str = q!AND (random text) AND (yet (more))!;