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 0991750e6ca55ec6f282c582cf8196f762f439c5..7aab1eaf94658cab1e118d2a421788607d6558be 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)) + ")$";
     }
 
     /*