![]() |
#1 |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Nov 2017
Device: Kindle
|
Small suggestion for the search regex documentation
I was trying to search with the regex "[A-Z][A-Z][A-Z]" — looking for 3 consecutive capital letters but the search operated case-insensitive so I was getting results ABC, AbC, abc etc which came as a considerable surprise.
I believe that this is because my install has LOCALE=en_GB and the collate order for that is case insensitive. I may be wrong, but it's my best guess and actually doesn't matter.* The Regex documentation page includes how to make a case sensitive [which is what we'd normally expect] ignore case with the "(?i)" syntax but not how to do the reverse. It actually turned out quite a chore tracking down what was required and a note in the documentation I feel would be useful. What I ended up with was Code:
(?-i:[A-Z]{3}) (*I am curious if this is true or something else caused it. If my guess is right then also mentioning that LOCALE can serious affect your regexes would also be useful.) |
![]() |
![]() |
![]() |
#2 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,170
Karma: 8800000
Join Date: Jun 2010
Device: Kobo Clara HD,Hisence Sero 7 Pro RIP, Nook STR, jetbook lite
|
Quote:
bernie Last edited by gbm; 11-25-2017 at 10:00 AM. Reason: second screenshot added |
|
![]() |
![]() |
Advert | |
|
![]() |
#3 | |
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Nov 2017
Device: Kindle
|
Quote:
Even so, I still think noting (?-i) where (?i) is mentioned in the doc would be a nice thing to do. |
|
![]() |
![]() |
![]() |
#4 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,248
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
|
![]() |
![]() |
![]() |
#5 | ||||
Junior Member
![]() Posts: 5
Karma: 10
Join Date: Nov 2017
Device: Kindle
|
Quote:
I don't think that anyone who had encountered regexes before would expect them to ignore case; it's one of the first things you learn about them — they're precise (often in frustrating and unexpected ways, but that's a different subject). Anyone not familiar with them, trying them out with the help of the documentation would read right at the beginning Quote:
Quote:
Further on still we come to the part that shows how to flag ignore case Quote:
So I still feel that adding the reverse syntax would be nice. Mentioning the check-box and its effect at this point could also do users — new and experienced — a favour. The check-box only gets referenced once, right at the end under "Bulk editing metadata" which I skipped as I wasn't bulk editing metadata. It's not as if I were suggesting a radical change in the application itself; just that a few words be added to documentation. |
||||
![]() |
![]() |
Advert | |
|
![]() |
#6 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,195
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
In the several years that this feature has existed, yours is the first complaint I've heard about that checkbox. SO I dont think it is quite an un-intuitive as you suggest. However, adding more documentation is always good.
So you are welcome to suggest improvements to the documentation, it is maintained s a simple plain text file, here: https://github.com/kovidgoyal/calibr...ual/regexp.rst |
![]() |
![]() |
![]() |
#7 |
Age improves with wine.
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 571
Karma: 95229
Join Date: Nov 2014
Device: Kindle Oasis, Kobo Libra II
|
It's the same as the "/.../i" option in most regex engines. Or grep's -i option. It saves having to write "[Ff][Ii][Nn][Dd] [Tt][Hh][Ii][Ss]" to find "find this" in a case-insensitive way.
|
![]() |
![]() |
![]() |
Tags |
locale, regex, search |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Regex in search problems (NOT Search&Replace; the search bar) | lairdb | Calibre | 3 | 03-15-2017 07:10 PM |
Regex Search doesn't search all files in Edit Book | GregTheGrate | Editor | 8 | 11-08-2016 12:47 AM |
A small suggestion for the settings backup | kaufman | Calibre Companion | 4 | 09-02-2016 04:04 PM |
Small improvement suggestion | elibrarian | Sigil | 4 | 03-04-2015 06:12 PM |
"Setting up a calibre development environment" documentation suggestion | trying | Development | 1 | 03-30-2014 10:25 PM |