title: Is there a clean way to get only string literals from a regex using Java?
body: <p>I am working in Java/Groovy and have a bunch of regular expressions that I need to test for invalid characters. But those characters appear in some of the wildcards, character classes, and escaping, so I would like to pull those out.</p>
  <p>So for example I'd like to extract, <code>abc</code> from <code>\d{4}abc.*</code> and <code>\123</code> from <code>\\123</code>, etc.</p>
  <p>Is there a library out there or a better way to approach this than using some hackey regular expressions myself?</p>
  <p>NOTE: I am not suggestion that some of these regular expressions are invalid AS REGULAR EXPRESSIONS. Rather they represent strings that may violate external constraints.</p>
  <p>Thanks!</p>