#10323 closed defect (worksforme)
Eval functions: regexp_test() and regexp_match() matching part of the string
Reported by: | plepe | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core mappaint | Version: | |
Keywords: | Cc: |
Description (last modified by ) ¶
I noticed that the eval functions regexp_test() and regexp_match() needs a pattern which matches the whole input, and in case you just want to match a part of the input you have to add ".*" in the beginning and the end. This is not as I expected it (and I guess most other people would expect it). In fact it took me some time testing patterns and a final email to one of the developers to solve it.
Anyway. I think this doesn't even really make sense, especially for the regexp_match() function, which returns the matched substring as 0th element of the array (which will always be the whole string).
Also, it contradicts the regexp condition selector: node[shop=~/market/]
matches "supermarket" as well as "marketplace".
I would suggest to change regexp_test() and regexp_match() to match substring of the input string. You can always add ^
and $
to match the whole string. If this is not possible, maybe it would be possible to add a flag and improve documentation?
Change History (4)
comment:1 by , 11 years ago
Description: | modified (diff) |
---|
comment:2 by , 11 years ago
Description: | modified (diff) |
---|
comment:3 by , 10 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
comment:4 by , 10 years ago
Lame.
How come, the regexp condition selector in JOSM works differently? Why don't you need to add .* there? Why does it make sense to return the matched substring as 0th element of the array (because it will always be the whole input string)?
That's how regexp work in Java. The "bible" on the subject is the javadoc of Pattern.
We won't change this behaviour, you have stated in your bug reports all the solutions needed to overcome the potential issues :)
If you think some points need to be clarified on the wiki, feel free to improve the documentation. It's a wiki and we value very high the input of our community :)