[josm-dev] [PATCH] Regex support for search

Ævar Arnfjörð Bjarmason avarab at gmail.com
Thu Jan 8 13:59:34 GMT 2009


The attached patch adds regex support to search, this solves trac
ticket #1864 [1][2], it adds a new "regex search" checkbox to the
search dialog below "case sensitive". If it's checked the pattern
given will be compiled as a regex with java.util.regex, e.g.:

^hig.*?[way]+$ # Matches in both keys and values
^foo$:[bar]       # Seperate regexes for the key and value

Patterns are case-insensitive by default, if the "case sensitive"
checkbox is checked they will be compiled with
Pattern.CASE_INSENSITIVE set (instead of lower casing the regex or
pattern which would screw things up).

If the user enters an invalid regex a dialog like this (by throwing
ParseError) shows up:

http://flickr.com/photos/avarab/3178963199/sizes/o/

It is of course translatable but the "full error" part comes directly
from Java's e.getMessage() exception method and may thus not be in the
same language as the rest of the JOSM interface. Although Java
implementations might have it localized. I think this is acceptable
given the limitations, the alternative is to provide a "regex
compilation failed" error without any further detail.

1. http://josm.openstreetmap.de/ticket/1864
2. I couldn't submit it to trac, it gave me: "500 Internal Server
Error (Submission rejected as potential spam (Content contained
blacklisted patterns))"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: josm-rx-search.patch
Type: text/x-diff
Size: 14910 bytes
Desc: not available
URL: <http://lists.openstreetmap.org/pipermail/josm-dev/attachments/20090108/377e570d/attachment.patch>


More information about the josm-dev mailing list