I would suggest not allowing the users to chose wether or not their search is case insensitive.
Then you could strip out the leading and trailing /'s if somebody were to enter your Perl-knowledgeable regex. Change all
lonely *'s to .+?'s or some such. Eval it to make sure it's valid. then do your search.
From the Ram Book
sub is_valid_pattern {
my $pat = shift;
return eval { "" =~ /$pat/; 1 } || 0;
}