Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

“regular expression” in “Create class” does not support full RE syntax #6962

Open
kaimikael opened this issue Dec 20, 2024 · 1 comment
Labels
meal This will take a day or two wish

Comments

@kaimikael
Copy link

What's wrong?

The documentation for “Create class” says: “Substring: regex-defined substring that will match the values from the above-defined attribute”
I took this to mean that you can define an arbitrary regular expression in the Substring field, but as can be seen in the attached screenshot, when I entered .*—which should match any string—I got no matches at all. I have played around with the input and it seems that what you enter is actually treated as a literal substring to be matched. If this is the intended behaviour, then please treat this as a feature request:
I’d like the Substring field to support the full Python regular expression syntax, including \number, so that matched substrings can be used in the Name section. In my concrete case I want to enter the Substring (.*) \([12]\) and use \1 in the Name field, so that the item Belgium (2) is renamed Belgium.

Failing that, “regex-defined” should be deleted from the documentation text.

How can we reproduce the problem?

Input any data. Connect to a “Create Class” widget. Select any string feature. Enter .* as Substring. Note that no strings are matched.

What's your environment?

Screenshot 2024-12-20 at 11 45 44
@kaimikael kaimikael added the bug report Bug is reported by user, not yet confirmed by the core team label Dec 20, 2024
@janezd janezd self-assigned this Jan 10, 2025
@janezd
Copy link
Contributor

janezd commented Jan 10, 2025

Documentation is wrong. This widget always matched just substrings, not regular expressions.

But instead of fixing the documentation, we could fix the widget. :) Matching regular expressions sounds useful and should be trivial to implement. The user would control it with a checkbox. The widget has plenty of space for it.

@janezd janezd added wish meal This will take a day or two and removed bug report Bug is reported by user, not yet confirmed by the core team labels Jan 10, 2025
@janezd janezd removed their assignment Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meal This will take a day or two wish
Projects
None yet
Development

No branches or pull requests

2 participants