zealdocs / zeal

Offline documentation browser inspired by Dash
https://zealdocs.org
GNU General Public License v3.0
11.39k stars 778 forks source link

Search with regular expression #676

Open NicolasWebDev opened 7 years ago

NicolasWebDev commented 7 years ago

Per issues #100 and #483, it seems that zeal supports fuzzy search.

Personally I would like much more to have search by regular expression, which gives much more control to the programmer.

Also I guess it would not be that hard to implement, only using the standard regex library in C++.

The best would be to have it configurable in the settings actually.

Thank you for your great work, zeal is one of the most important element of my toolbox!

trollixx commented 7 years ago

While the idea sounds interesting, I am not sure what impact it would have on search performance. Perhaps with SQLite's built-in support for regular expressions it may work.

NicolasWebDev commented 7 years ago

I guess we would have two search modes then:

Because the choice of the mode can be selected, low performance would not impact current use. Speaking for myself, the search is really really fast, what takes me the most time by far is filtering the results "by eyes" to find exactly what I am looking for.

If you have a look at this SO question, it seems that by default SQLite does not implement regexes. But there are packages (like the mentioned sqlite3-pcre), that implements regexes.

In this precise one (sqlite3-pcre), regexes are the pearl ones, which is really powerful and kind of a standard syntax. In my archlinux box, I have sqlite-pcre-git in the aur.

Seems that the ICU extension to SQLite gives also an implementation of the regexp operator.

Else there is this page that gives an example creating the regexp() function from the one provided by the language of the application (C++/qt).

I think the best would be to look at how sqlitebrowser implemented it, using the Qt regexp engine (that uses pearl syntax it seems). Here they give some details.