Part of the code I'm working on uses a bunch of regular expressions to search for some simple string patterns (e.g., patterns like "foo[0-9]{3,4} bar"). Currently, we use statically-compiled Java Patterns and then call Pattern#matcher to check whether a string has contains a match to the pattern (I don't need the match, just a boolean indicating whether there is a match). This is causing a noticeable amount of memory allocation that is affecting performance.
Is there a better option for Java regex matching that is faster or at least doesn't allocate memory every time it searches a string for a pattern?