#!/usr/bin/perl -w use 5.018; # 1126143 my $line = ' [Category("notestrecord")]'; my $pattern = qr/["()Cacdegnorsty]/; if($line =~ /\s*$pattern/) { print "Matched |$pattern| in |$line|"; # vbars to show spaces (& lack of spaces) } else { print "No match!"; } =head OUTPUT: Matched |(?^u:[Category("notestrecord")])| in | [Category("notestrecord")]| =cut