This could be attained by rewriting the script using the /filter command, and this would be a *bit* faster. But in this case, I'd prefer changing only the read command line: to a regex search.
Change this line:
while ($read(quotes.txt,nw,* $+ $2- $+ *,%nr)) {
to:
while ($read(quotes.txt,ntr,$+(/\d+\\.*\Q,$2-,\E.*\\.+\\/i),%nr)) {
Trying to explain the regular expression part $+(/\d+\\.*\Q,$2-,\E.*\\.+\\/i)
(I'm not that good with regex, hope it works at all
)
$+(/\d+\\.*\Q
,$2-
,\E.*\\.+\\/i
) -> sticking the other parts together with the provided search term "$2-"
$+(
/\d+\\.*\Q,$2-,\E.*\\.+\\
/i) -> marking the beginn and end of the regular expression, the flag "i" makes the whole regular expression in-between the two // match case-insensitive
$+(/
\d+\\.*\Q,$2-,\E.*\\.+\\/i) -> one or more digits (the "line #" part)
$+(/\d+
\\.*\Q,$2-,\E.*
\\.+
\\/i) -> the backslash to separate the parts: line # - quote - added by and date - rating (the \ char is a char that had to be "escaped" inside regular expressions, else it would have another meaning)
$+(/\d+\\
.*\Q,$2-,\E
.*\\.+\\/i) -> zero or more occurances of some char (this works like the * in ordinary wilcard comparisons)
$+(/\d+\\.*
\Q,$2-,
\E.*\\.+\\/i) -> start and end of a "literal" part (that is: the text in between is matched as plain text (else a dot would not mean a literal dot etc... like the backslash thingie above)
$+(/\d+\\.*\Q,$2-,\E.*\\
.+\\/i) -> one or more occurances of some char (this is the part "added by and time")
Note: You cannot use wildcards
inside the matchword part any longer, as the asterisk char is now treated as 'plain text'.
That is: if someone types "!qfind test", the script will check the quotes part of your text file for wildcard matches of *test* - as it did before. But "!qfind *test*" would now mean a search for
**test
** (blue ones being literal asterisks, red ones being the 'wildcard search')