my $full_text = "(7001) - This is some text"; my $check_str = "([7000|7001|7002|7003]) - This"; $check_str =~ s/([()])/\\$1/g; $check_str =~ s/\[/(?:/g; $check_str =~ s/\]/)/g; if ($full_text =~ /$check_str/) { print "full_text has the check_str\n"; }