Assuming I have a `List<String>` and an empty `List<Pattern>`, is this the best way to handle making the words in the String into Pattern objects;

```
for(String word : stringList) {
    patterns.add(Pattern.compile("\\b(" + word + ")\\b);
}

```

And then to run this on a string later;

```
for(Pattern pattern : patterns) {
    Matcher matcher = pattern.matcher(myString);
    if(matcher.matches()) {
         myString = matcher.replaceAll("String[$1]");
    }
}

```

The replaceAll bit is just an example, but $1 would be used most of the the time when I use this.

Is there a more efficient way? Because I feel like this is somewhat clunky. I'm using 80 Strings in the list by the way, though the Strings used are configurable, so there won't always be so many.

This is designed to be somewhat of a swearing filter so I'll let you assume the words in the List,

An example of input would be `"You're a <curse>"`, the output would be `"You're a *****"` for this word, though this may not always be the case and at some point I may be reading from a `HashMap<String, String>`where the key is the capture group and the value is the replacement.

Example:

```
if(hashMap.get(matcher.group(1)) == null) { 
    // Can't test if \ is required. Used it here for safe measure.
    matcher.replaceAll("\*\*\*\*");
 } else {
    matcher.replaceAll(hashMap.get(matcher.group(1));
 }

```