-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6ba92a0
commit 083c0da
Showing
10 changed files
with
98 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,15 @@ Prefixing a query with `^` will match notes whose title or body start with the f | |
"title: ^journal" | ||
``` | ||
|
||
### Search for special characters | ||
|
||
If you need to find patterns containing special characters, such as an `[email protected]` or a `[[wiki-link]]`, use the `--exact-match` / `-e` option. The search will be case-insensitive. | ||
|
||
``` | ||
$ zk list --exact-match --match "[[link]]" | ||
$ zk list -em "[[link]]" | ||
``` | ||
|
||
## Filter by tags | ||
|
||
You can filter your notes by their [tags](tags.md) using `--tags` (or `-t`). | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package sqlite | ||
|
||
import "strings" | ||
|
||
// escapeLikeTerm returns the given term after escaping any LIKE-significant | ||
// characters with the given escapeChar. | ||
// This is meant to be used with the ESCAPE keyword: | ||
// https://www.sqlite.org/lang_expr.html | ||
func escapeLikeTerm(term string, escapeChar rune) string { | ||
escape := func(term string, char string) string { | ||
return strings.ReplaceAll(term, char, string(escapeChar)+char) | ||
} | ||
return escape(escape(escape(term, string(escapeChar)), "%"), "_") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package sqlite | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/mickael-menu/zk/internal/util/test/assert" | ||
) | ||
|
||
func TestEscapeLikeTerm(t *testing.T) { | ||
test := func(term string, escapeChar rune, expected string) { | ||
assert.Equal(t, escapeLikeTerm(term, escapeChar), expected) | ||
} | ||
|
||
test("foo bar", '@', "foo bar") | ||
test("foo%bar_with@", '@', "foo@%bar@_with@@") | ||
test(`foo%bar_with\`, '\\', `foo\%bar\_with\\`) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters