my @out = split(\s(AND|OR)\s/i,$string); #### my @out = split(/\s(AND|OR)\s/i,$string); #### #!/usr/bin/perl -wT use strict; my $string = "something and something else or this thing here"; my $new = join(' ', map {/^(and|or)$/ ? uc($_) : "tools.description LIKE \"%$_%\""} split(/\s*\b(and|or)\b\s*/,$string)); print "S:$string\n"; print "N:$new\n"; =OUTPUT S:something and something else or this thing here N:tools.description LIKE "%something%" AND tools.description LIKE "%something else%" OR tools.description LIKE "%this thing here%"