title: I can't use a group name like this "abc_def" using Patterns
body: <p>I have a problem with a series of patterns that have to be compiled. Here is an example:</p>
  
  <pre><code>...(?&lt;NOT&gt;\bNOT\b)|(?&lt;LEFT_PAR&gt;\()|(?&lt;RIGHT_PAR&gt;\))...
  </code></pre>
  
  <p>These group names "LEFT_PAR" and "RIGHT_PAR" raise an exception:</p>
  
  <pre><code>Exception in thread "main" java.util.regex.PatternSyntaxException: 
  named capturing group is missing trailing '&gt;'
  </code></pre>
  
  <p>I'm pretty sure that the underscore is the problem. Searching online I didn't find anything helpful and I can't understand why this _ is causing me this issue when i saw examples in python working great. I've read that it is treated like a normal char in Java Patterns. Obviously, if I delete it, it works great.</p>
  
  <p>Can you help me, please? :)
  Thanks. </p>
  
  <p>EDIT:</p>
  
  <pre><code> public enum Patterns(){
     NOT("\\bNOT\\b"),
     LEFT-PAR("\\("), 
     RIGHT-PAR("\\)"); [...] 
   }
   //i'm cutting enum constructor and toString() method...
  
  //That's the part of the method that uses enum
  
  StringBuilder allPatterns = new StringBuilder();
  
  //This loop creates a unique group of patterns (key-value)
  for (validTokens t : validTokens.values()) 
      allPatterns.append("|(?&lt;" + t.name() + "&gt;" + t + ")");
  
  //Compile all Patterns and create a group
  Pattern pattern = Pattern.compile(allPatterns.toString().substring(1)); //ERROR 
  </code></pre>
  
  <p>I can't change any of the names because of project's specifics. The method and the enum worked well until now... This _ ruined all xD If you can help me to figure out, please.
  Thanks.</p>