[Schmitzm-commits] r2157 - in trunk/schmitzm-core/src: main/java/de/schmitzm/regex test/java/de/schmitzm test/java/de/schmitzm/regex
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Sat Dec 8 23:15:24 CET 2012
Author: alfonx
Date: 2012-12-08 23:15:24 +0100 (Sat, 08 Dec 2012)
New Revision: 2157
Added:
trunk/schmitzm-core/src/test/java/de/schmitzm/regex/
trunk/schmitzm-core/src/test/java/de/schmitzm/regex/RegexCacheTest.java
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
Log:
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java 2012-12-08 22:09:55 UTC (rev 2156)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/regex/RegexCache.java 2012-12-08 22:15:24 UTC (rev 2157)
@@ -145,8 +145,12 @@
}
}
- private boolean looksLikeRegex(final String regex) {
- return RegexCache.getInstance().matches("[\\[\\]()?\\\\+{}]", regex);
+ String ERKENNE_REGEX_RX = "[\\[\\]()?\\\\+{}^$]";
+
+ public boolean looksLikeRegex(final String suchString) {
+ // Kein Matches hier verwenden!
+ // return matches(ERKENNE_REGEX_RX, regex);
+ return result(ERKENNE_REGEX_RX, suchString) != null;
}
// public final boolean matches(final String regex, final Object object) {
Added: trunk/schmitzm-core/src/test/java/de/schmitzm/regex/RegexCacheTest.java
===================================================================
--- trunk/schmitzm-core/src/test/java/de/schmitzm/regex/RegexCacheTest.java (rev 0)
+++ trunk/schmitzm-core/src/test/java/de/schmitzm/regex/RegexCacheTest.java 2012-12-08 22:15:24 UTC (rev 2157)
@@ -0,0 +1,19 @@
+package de.schmitzm.regex;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import de.schmitzm.testing.TestingClass;
+
+public class RegexCacheTest extends TestingClass {
+ @Test
+ public void testLooksLikeRegex() {
+ RegexCache rC = RegexCache.getInstance();
+
+ assertTrue(rC.looksLikeRegex("^Brezeln"));
+ assertTrue(rC.looksLikeRegex("Um mit (?:dir|das) Brezeln"));
+ assertTrue(rC.looksLikeRegex("Um mit [asd] Brezeln"));
+ assertFalse(rC.looksLikeRegex("asd"));
+ }
+}
Property changes on: trunk/schmitzm-core/src/test/java/de/schmitzm/regex/RegexCacheTest.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
More information about the Schmitzm-commits
mailing list