Quote:
Originally Posted by kovidgoyal
iirc the regex is treated as case-insensitive which is why a-z matches upper case letters as well.
|
RegEx cheat-sheets that I have say that it should be case-sensitive and i is used for making it case-insensitive.
Example:
https://www.rexegg.com/regex-modifiers.html
I searched StackOverflow but all of the questions were about how to make RegEx case-insensitive.
Perhaps the RegEx engine that Calibre uses is case-insensitive? But if so, is there a way to make it case-sensitive?
=== EDIT ===
This text has been quoted from the link above:
Quote:
For several engines, note that there are two ways of turning on case-insensitive matching: as an inline modifier (?i) or as an option in the regex method or function.
Inline Modifier (?i)
In .NET, PCRE (C, PHP, R…), Perl, Python, Java and Ruby (but not JavaScript), you can use the inline modifier (?i), for instance in (?i)cat. See the section on inline modifiers for juicy details about three additional features (unavailable in Python): turning it on in mid-string, turning it off with (?-i), or applying it only to the content of a non-capture group with (?i:foo)
.NET
Apart from the (?i) inline modifier, .NET languages have the IgnoreCase option. For instance, in C# you can use:
var catRegex = new Regex("cat", RegexOptions.IgnoreCase);
Perl
Apart from the (?i) inline modifier, Perl lets you add the i flag after your pattern's closing delimiter. For instance, you can use:
if ($the_subject =~ m/cat/i) { … }
PCRE (C, PHP, R…)
Note that in PCRE, to use case-insensitive matching with non-English letters that aren't part of your locale, you'll have to turn on Unicode mode—for instance with the (*UTF8) special start-of-pattern modifier.
Apart from the (?i) inline modifier, PCRE lets you set the PCRE_CASELESS mode when calling the pcre_compile() (or similar) function:
cat_regex = pcre_compile( "cat", PCRE_CASELESS,
&error, &erroroffset, NULL );
|
Perhaps in the Calibre code, RegEx function has been called with case-insensitive command option? If yes, would it be possible to turn it off, please? :P