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

Group dynamic collection: RegEx for 'owner' field returning empy and non-three-letters #398

Closed
2 tasks done
CrocodileDandy opened this issue Aug 25, 2022 · 6 comments · Fixed by #401
Closed
2 tasks done

Comments

@CrocodileDandy
Copy link

JabRef version

Other (please describe below)

Operating system

Windows

Details on version and operating system

Windows 10 21H2, JabRef 5.1

Checked with the latest development build

  • I made a backup of my libraries before testing the latest development version.
  • I have tested the latest development version and the problem persists

Steps to reproduce the behaviour

I fail to find library entries where the Owner field is left empty using a dynamic group based on collection by a search for keywords and a regex.

I have a shared library where every user is required to use the setting to mark new entries with their username (General > Entry owner > ☑ Mark new entries with owner name). I want to check this by gathering the entries where the Owner field is empty (or does not match the required pattern) in a dynamic group.
For this purpose, I have created a dynamic group where entries are collected by searching for keywords in the Owner field using the following regex: ^(?![a-zA-Z]{3}$). This regex will match if the content of the field is different from three letters, either lower or upper case. I checked it on https://regex101.com/
Unfortunately, no entry is added to the group.

Is that normal behavior? What am I missing here?

To reproduce:

  1. Install JabRef 5.1 (although testing on 5.7 led to the same behavior so you should be able to reproduce there).
  2. Create some libraries entries, some with the Owner field filled with three letters only and some left empty or with a different content.
  3. Create a dynamic group where items are collected by searching for keywords in the Owner field using the following regex: ^(?![a-zA-Z]{3}$)

Appendix

...

Log File
Paste an excerpt of your log file here
@ryan-carpenter
Copy link

I get the same result in JabRef 5.8. The reason seems to be disappearance of the owner field when it is blank or contains only spaces. This is also the case for other fields such as an empty title, and it does not matter how or where I search; that is, using the search box or through a group, with or without regex. A regex search for .* does not match the target and neither does "" without regex. This seems like a bug, since I do not think it has always been this way.

@ThiloteE
Copy link
Member

"Searching for a keyword" has certain limitations which depend on the way fields are created and deleted in JabRef (e.g. empty fields "do not exist") and it could be that you just hit one of these bugs.
grafik

"Free search expression" does have less limitations. Though, there are different versions of RegEx, so it could be that the bug also stems from using wrong RegEx syntax. JabRef uses a java based one from Oracle. Have a look at the JabRef documentation about advanced search or Oracles RegEx docs.

In particular the following will be of interest to you:

author != .+ returns entries with empty or no author field.

I have a group with a similar line to search for entries without a group (Refs JabRef/jabref#7871):

grafik

You could adapt this line to something like this:

owner != .+

and then add your other conditions to it.

@ryan-carpenter
Copy link

@CrocodileDandy 's expression combined with @ThiloteE 's suggestion works as intended, returning empy and non-three-letter owners. The Case sensitive option also works with this:

owner != ^[a-zA-Z]{3}$

For empy fields, all you need is the first character; like this (either one):

  • owner != .
  • owner != ^

1774_JabRef

@ThiloteE ThiloteE changed the title Group dynamic collection fails to parse the 'owner' field using a regex Group dynamic collection: RegEx for 'owner' field returning empy and non-three-letters Aug 27, 2022
@ThiloteE
Copy link
Member

Issue solved.

Might be nice to put this into the RegEx documentation, therefore transferring this to the documentation repository.

@ThiloteE ThiloteE transferred this issue from JabRef/jabref Aug 27, 2022
@ThiloteE ThiloteE reopened this Sep 2, 2022
@ThiloteE
Copy link
Member

ThiloteE commented Sep 2, 2022

Reopened because this could be something for JabRef's documentation and webpage. @CrocodileDandy, if you don't want to receive further notifications, you can unsubscribe them for this specific issue.

@Siedlerchr
Copy link
Member

@ThiloteE Go ahead and add it to the documentation ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants