title: Enumerate Possible Matches of Regular Expression in Java
body: <p>I want to enumerate all the possible values of a finite regular expression in Java for testing purposes.</p>
  
  <p>For some context, I have a regular expression that I'm using to match allowable color values in words. Here's a shortened version of it as an example:</p>
  
  <pre><code>(white|black)|((light|dark) )?(red|green|blue|gray)
  </code></pre>
  
  <p>I wanted to create a unit test that would enumerate all these values and pass each of them to my utility class which produces a <code>Color</code> object from these, that way if I change the regular expression, my unit tests will fail if an error occurs (i.e. the new color value is unsupported).</p>
  
  <p>I know enumeration is possible, of course (<a href="https://stackoverflow.com/questions/6643730/producing-all-possible-matches-of-a-regular-expression">see this question</a>), but is there an existing library for Java which will enumerate all the possible matches for a regex?</p>
  
  <p><strong>Edit:</strong> I've implemented a library that does this. See my answer below for links.</p>