What's a Regex (Regular Expression) and how to use it?
A regular expression is defined as "a sequence of characters that define a search pattern".
It is an extremely useful tool to improve the power of the search feature of NoteCase Pro. Note that pattern matching and captures in the embedded Lua scripting language have their own different and simpler pattern matching/capture syntax. See Lua Reference Manual section 6.4.1. https://www.lua.org/work/doc/manual.html#6.4.1.
There are many examples around on the Internet that are ready to use. If you often do complicated searches, you may want to learn the rules patterns and captures are built from and build your own. The rules are simple. The combinations that are possible can become complicated.
If it's better for your particular use case to learn the rules and develop your own expressions, or if you search the web for a matching predefined expression that you can use, depends on how often and for what purposes you want to use them.
Examples:
This is a simple regular expression that's almost intuitive. It matches any word that is longer than 25 characters:
[A-Za-z]{25,}
This one matches "hat" and "cat":
[hc]at
This one maches any email address:
^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$
This looks complicated?
This Regex also matches e-mail addresses, considering the standard RFC 2822:
^((?>[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+\x20*|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*"\x20*)*(?<angle><))?((?!\.)(?>\.?[a-zA-Z\d!#$%&'*+\-/=?^_`{|}~]+)+|"((?=[\x01-\x7f])[^"\\]|\\[\x01-\x7f])*")@(((?!-)[a-zA-Z\d\-]+(?<!-)\.)+[a-zA-Z]{2,}|\[(((?(?<!\[)\.)(25[0-5]|2[0-4]\d|[01]?\d?\d)){4}|[a-zA-Z\d\-]*[a-zA-Z\d]:((?=[\x01-\x7f])[^\\\[\]]|\\[\x01-\x7f])+)\])(?(angle)>)$
The more variants and the more precise a Regex should be, the more complex it can become.
This one matches a date formatted according to ISO 8601 (yyyy-mm-dd, e.g.: 2017-04-12):
\d{4}-\d{2}-\d{2}
This one also matches ISO 8601 dates, but does not match non-existent dates, such as 2004-04-31 or 2004-02-30:
^[0-9]{4}-(((0[13578]|(10|12))-(0[1-9]|[1-2][0-9]|3[0-1]))|(02-(0[1-9]|[1-2][0-9]))|((0[469]|11)-(0[1-9]|[1-2][0-9]|30)))$
You see how powerful this tool is.
Regular expression queries can be used in searches from the Find dialog and from the Replace dialog, accessed using Ctrl+F and Ctrl+H respectively; however, this feature is currently not supported on the Maemo platform because GTK+ 2.12 or later is not yet available for Maemo.
NoteCase Pro incorporates the glib library (part of the GTK+ stack), which includes the popular Perl Compatible Regular Expressions ("PCRE") engine. A regular expression search (commonly referred to as a regex) identifies text patterns rather than precise strings of text; e.g., search for all email addresses or for dates within a range.
The syntax for writing PCRE regex queries is here. http://regexkit.sourceforge.net/Documentation/pcre/pcresyntax.html.
Additional Regex Resources
When viewing sites on the Web dealing with regexes, please remember that not all regex engines or their syntaxes are the same. Those dealing with PCRE specifically will be most reliable for working with PCRE in NoteCase Pro's Find dialog.
Regular-Expressions.info Tutorial
A good regular expression tutorial aimed at the beginner level user.
Regular Expression Library
"Currently we have indexed 24,332 expressions from 2905 contributors around the world. We hope you'll find this site useful and come back whenever you need help writing an expression, you're looking for an expression for a particular task, or are ready to contribute new expressions you've just figured out." (As of July 30, 2020.)
Regular Expressions web sites
"Within the Regular Expressions, aka Regex, section you'll find helpful annotated links to articles, tutorials, scripts, regular expressions cheat sheets, charts and more related to regular expressions. In addition are listings of online forums and websites devoted to regular expressions, and other regex links resources. You'll also find a listing of recommended books on regular expressions."