Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#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 plepe)

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?

Attachments (0)

Change History (4)

comment:1 Changed 6 years ago by plepe

Description: modified (diff)

comment:2 Changed 6 years ago by plepe

Description: modified (diff)

comment:3 Changed 6 years ago by Don-vip

Resolution: worksforme
Status: newclosed

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 :)

comment:4 Changed 6 years ago by plepe


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)?

Modify Ticket

Change Properties
Set your email in Preferences
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted.

Add Comment

E-mail address and name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.