Changes between Initial Version and Version 1 of Ticket #23943
- Timestamp:
- 2024-09-29T19:58:50+02:00 (12 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #23943
- Property Summary Mapcss "substring" function: allow negative end index to remove from the end → [PATCH] Mapcss "substring" function: allow negative end index to remove from the end
-
Ticket #23943 – Description
initial v1 19 19 A much nicer solution would be to permit negative end indices in the `substring(str, start, end)` function, which should mean to count the final index from the length of the string, e.g.: `substring("foo bar baz", 1, -1)` would return `oo bar ba`. This is especially useful for variable-length strings in mapcss. 20 20 21 I'm not familiar enough with Java to dare to make it a patch, but I can image the new function to look something like:21 A possible patch: 22 22 {{{#!java 23 23 public static String substring(String s, float begin, float end) { 24 return s == null ? null : s.substring((int) begin, (int) (end > 0 ? end : s.length() + end)); 24 return s == null ? null : s.substring((int) begin, (int) (end >= 0 ? end : s.length() + end)); 25 25 } 26 26 }}}