/background-color:\s*#([0-9a-fA-F]{6});*/ig #### my $pattern1 = 'background-color: #FAF519;'; my $pattern2 = 'background-color: #A7D6D5;';