- Timestamp:
- 2020-04-11T17:37:01+02:00 (5 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/search/PushbackTokenizer.java
r12656 r16260 108 108 EQUALS(marktr("<equals>")), 109 109 /** 110 * The tilde sign (~) 111 */ 112 TILDE(marktr("<tilde>")), 113 /** 110 114 * A text 111 115 */ … … 148 152 } 149 153 150 private static final List<Character> SPECIAL_CHARS = Arrays.asList('"', ':', '(', ')', '|', '^', '=', ' ?', '<', '>');154 private static final List<Character> SPECIAL_CHARS = Arrays.asList('"', ':', '(', ')', '|', '^', '=', '~', '?', '<', '>'); 151 155 private static final List<Character> SPECIAL_CHARS_QUOTED = Arrays.asList('"'); 152 156 … … 200 204 getChar(); 201 205 return Token.EQUALS; 206 case '~': 207 getChar(); 208 return Token.TILDE; 202 209 case '<': 203 210 getChar(); -
trunk/src/org/openstreetmap/josm/data/osm/search/SearchCompiler.java
r16259 r16260 2119 2119 if (tokenizer.readIfEqual(Token.EQUALS)) { 2120 2120 return new ExactKeyValue(regexSearch, key, tokenizer.readTextOrNumber()); 2121 } else if (tokenizer.readIfEqual(Token.TILDE)) { 2122 return new ExactKeyValue(true, key, tokenizer.readTextOrNumber()); 2121 2123 } else if (tokenizer.readIfEqual(Token.LESS_THAN)) { 2122 2124 return new ValueComparison(key, tokenizer.readTextOrNumber(), -1); -
trunk/src/org/openstreetmap/josm/gui/dialogs/SearchDialog.java
r15292 r16260 294 294 .addKeyword("<i>key</i>", null, tr("matches if ''key'' exists")) 295 295 .addKeyword("<i>key</i>=<i>value</i>", null, tr("''key'' with exactly ''value''")) 296 .addKeyword("<i>key</i>~<i>regexp</i>", null, tr("value of ''key'' matching the regular expression ''regexp''")) 296 297 .addKeyword("<i>key</i>=*", null, tr("''key'' with any value")) 297 298 .addKeyword("<i>key</i>=", null, tr("''key'' with empty value")) -
trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java
r14561 r16260 142 142 143 143 /** 144 * Search by regular expression: key~value. 145 * @throws SearchParseError if an error has been encountered while compiling 146 */ 147 @Test 148 public void testRegexp() throws SearchParseError { 149 final SearchCompiler.Match c = SearchCompiler.compile("foo~[Bb]a[rz]"); 150 assertFalse(c.match(newPrimitive("foobar", "true"))); 151 assertFalse(c.match(newPrimitive("foo", "foo"))); 152 assertTrue(c.match(newPrimitive("foo", "bar"))); 153 assertTrue(c.match(newPrimitive("foo", "baz"))); 154 assertTrue(c.match(newPrimitive("foo", "Baz"))); 155 assertEquals("foo=[Bb]a[rz]", c.toString()); 156 } 157 158 /** 144 159 * Search by comparison. 145 160 * @throws SearchParseError if an error has been encountered while compiling
Note:
See TracChangeset
for help on using the changeset viewer.