I'm converting a perl program to java. In the perl script a value that is read from a file is checked against hundreds of regex patterns. I would like not to do this statically as it's been done in the original perl program. Is there any sort of design pattern that can be used to make this more dynamic?
This is a single line of the current code:
$flag++ if ($Part_Name =~ /(harmonic|nsg|white\ sands|sphix|battery|collection|allied)/i);
Now repeat that for another 50-60 lines and that's how many there are. The unique strings that are being tested against are in fact stand alone, all we care at the end is if ($flag > 0).