Encapsulate regexes in a non-capturing group
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / RegexUtils.java
index 862d7e54591b2c6b96dac289cf9c83a959bdbb71..35187f26fd5a0e5d0b3317313379b8b6e4b90c90 100644 (file)
@@ -246,7 +246,8 @@ public final class RegexUtils {
      * @return Java-compatible regex
      */
     public static String getJavaRegexFromXSD(final String xsdRegex) {
-        return "^" + fixUnicodeScriptPattern(escapeChars(xsdRegex)) + '$';
+        // Note: we are using a non-capturing group to deal with internal structure issues, like branches and similar.
+        return "^(?:" + fixUnicodeScriptPattern(escapeChars(xsdRegex)) + ")$";
     }
 
     /*