. . . my $query = undef; if ($query =~ /^(([\w\d\-\_]+)[:,]|)(.*)$/) { # we get here! print "$`|$1|$2|$3|$4|$'|$query|"; } else { exit; } . . .