my $c = qr/(?>--[^\n]*(?:\n|\z))/; # VHDL comment regex #### # position 01234567 89 my $str = "a --b x\n x"; #### $str =~ m/$c* x/; #### $str =~ m/$c*x/;