0> In article <[email protected]>,
0> Thilo Hannemann <URL:mailto:[email protected]> ("Thilo") wrote:
Thilo> And finally one patch that you might want to apply: "start-with".
Thilo> This adds a text filter for variable substitution. You can say
Thilo> for example $ {name|start-with:Hospital }. This will put the
Thilo> string "Hospital " in front of the name, but only if that string
Thilo> doesn't contain "Hospital" somewhere already.
I like that idea! A corresponding 'end-with' would be really useful
(certainly in English, where the name usually comes before the function,
e.g. "Strathcarron Station").
Thilo> + searchPhrase = arg.trim().toLowerCase();
Thilo> + ...
Thilo> + if (value.toLowerCase().indexOf(searchPhrase) != -1)
That's not the best way to do a case-insensitive test - the reason being
that in some languages (e.g. French, I think) upper case letters have no
accents. So "Ecole" should match "école" (again, excuse my poor French
if necessary!). Also, in German, "Straße" should match "STRASSE".
Conversion of both values to uppercase is therefore a better simple
solution.
(I was surprised to find that java.text.Collator doesn't have an indexOf()
method - that's where I'd expect to do locale-dependent matching).
To do it properly, look at java.util.regexp - something like:
/--------
| searchPattern = Pattern.compile(Pattern.quote(arg.trim()),
| Pattern.UNICODE_CASE | Pattern.CANON_EQ);
| ...
| if (searchPattern.matcher(value).matches())
\--------
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev