my $pattern= $string_from_user; $pattern =~ s#(['%_\[\]])#\\$1#g; "... LIKE '%$pattern%' ..."