Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java	(revision 11561)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactory.java	(revision 11562)
@@ -14,4 +14,5 @@
 import java.util.function.Predicate;
 import java.util.regex.Pattern;
+import java.util.regex.PatternSyntaxException;
 
 import org.openstreetmap.josm.Main;
@@ -51,10 +52,16 @@
      * @param considerValAsKey whether to consider {@code v} as another key and compare the values of key {@code k} and key {@code v}.
      * @return The new condition.
+     * @throws MapCSSException if the arguments are incorrect
      */
     public static Condition createKeyValueCondition(String k, String v, Op op, Context context, boolean considerValAsKey) {
         switch (context) {
         case PRIMITIVE:
-            if (KeyValueRegexpCondition.SUPPORTED_OPS.contains(op) && !considerValAsKey)
-                return new KeyValueRegexpCondition(k, v, op, false);
+            if (KeyValueRegexpCondition.SUPPORTED_OPS.contains(op) && !considerValAsKey) {
+                try {
+                    return new KeyValueRegexpCondition(k, v, op, false);
+                } catch (PatternSyntaxException e) {
+                    throw new MapCSSException(e);
+                }
+            }
             if (!considerValAsKey && op.equals(Op.EQ))
                 return new SimpleKeyValueCondition(k, v);
@@ -339,4 +346,5 @@
          * @param op operation
          * @param considerValAsKey must be false
+         * @throws PatternSyntaxException if the value syntax is invalid
          */
         public KeyValueRegexpCondition(String k, String v, Op op, boolean considerValAsKey) {
Index: /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSException.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSException.java	(revision 11561)
+++ /trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSException.java	(revision 11562)
@@ -2,18 +2,43 @@
 package org.openstreetmap.josm.gui.mappaint.mapcss;
 
+/**
+ * MapCSS parsing error, with line/columnn information in error message.
+ */
 public class MapCSSException extends RuntimeException {
 
-    protected final String specialmessage;
+    /** line number at which the parse error occured */
     protected Integer line;
+    /** column number at which the parse error occured */
     protected Integer column;
 
+    /**
+     * Constructs a new {@code MapCSSException} with an explicit error message.
+     * @param specialmessage error message
+     */
     public MapCSSException(String specialmessage) {
-        this.specialmessage = specialmessage;
+        super(specialmessage);
     }
 
+    /**
+     * Constructs a new {@code MapCSSException} with a cause.
+     * @param cause the root cause
+     * @since 11562
+     */
+    public MapCSSException(Throwable cause) {
+        super(cause);
+    }
+
+    /**
+     * Sets the column number at which the parse error occured.
+     * @param column the column number at which the parse error occured
+     */
     public void setColumn(int column) {
         this.column = column;
     }
 
+    /**
+     * Sets the line number at which the parse error occured.
+     * @param line the line number at which the parse error occured
+     */
     public void setLine(int line) {
         this.line = line;
@@ -23,6 +48,6 @@
     public String getMessage() {
         if (line == null || column == null)
-            return specialmessage;
-        return String.format("Error at line %s, column %s: %s", line, column, specialmessage);
+            return super.getMessage();
+        return String.format("Error at line %s, column %s: %s", line, column, super.getMessage());
     }
 }
Index: /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactoryTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactoryTest.java	(revision 11562)
+++ /trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactoryTest.java	(revision 11562)
@@ -0,0 +1,32 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.gui.mappaint.mapcss;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context;
+import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.Op;
+import org.openstreetmap.josm.testutils.JOSMTestRules;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+
+/**
+ * Unit tests of {@link ConditionFactory}.
+ */
+public class ConditionFactoryTest {
+
+    /**
+     * Setup rule
+     */
+    @Rule
+    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+    public JOSMTestRules test = new JOSMTestRules().preferences();
+
+    /**
+     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/14368">#14368</a>.
+     * @throws Exception if an error occurs
+     */
+    @Test(expected = MapCSSException.class)
+    public void testTicket14368() throws Exception {
+        ConditionFactory.createKeyValueCondition("name", "Rodovia ([A-Z]{2,3}-[0-9]{2,4}", Op.REGEX, Context.PRIMITIVE, false);
+    }
+}
