Index: trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java
===================================================================
--- trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 11191)
+++ trunk/src/org/openstreetmap/josm/actions/search/SearchCompiler.java	(revision 11192)
@@ -889,5 +889,7 @@
                 } catch (PatternSyntaxException e) {
                     throw new ParseError(tr(rxErrorMsg, e.getPattern(), e.getIndex(), e.getMessage()), e);
-                } catch (IllegalArgumentException e) {
+                } catch (IllegalArgumentException | StringIndexOutOfBoundsException e) {
+                    // StringIndexOutOfBoundsException catched because of https://bugs.openjdk.java.net/browse/JI-9044959
+                    // See #13870: To remove after we switch to a version of Java which resolves this bug
                     throw new ParseError(tr(rxErrorMsgNoPos, s, e.getMessage()), e);
                 }
Index: trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java	(revision 11191)
+++ trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java	(revision 11192)
@@ -9,4 +9,5 @@
 import org.junit.Rule;
 import org.junit.Test;
+import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting;
 import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
@@ -449,3 +450,16 @@
         assertTrue(SearchCompiler.compile(search2).match(tag2));
     }
+
+    /**
+     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/13870">Bug #13870</a>.
+     * @throws ParseError always
+     */
+    @Test(expected = ParseError.class)
+    public void testPattern13870() throws ParseError {
+        // https://bugs.openjdk.java.net/browse/JI-9044959
+        SearchSetting setting = new SearchSetting();
+        setting.regexSearch = true;
+        setting.text = "[";
+        SearchCompiler.compile(setting);
+    }
 }
