# Workaround for finding round brackets - "(" and ")"

**URL:** <https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127>\
**Category:** Help\
**Created:** [November 14, 2020, 4:28pm UTC](https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127 "2020-11-14T16:28:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![joojanta](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@joojanta](https://forums.ankiweb.net/u/joojanta)\
**Post date:** [November 14, 2020, 4:28pm UTC](https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127/1 "2020-11-14T16:28:11Z")

</div>

Quite recently, Anki drove me crazy over trying to find round brackets. Then I found a thread of earlier this year [Cannot search for round brackets](https://anki.tenderapp.com/discussions/ankidesktop/39597-cannot-search-for-round-brackets) (closed, cannot comment there) - just to find out that this problem hasn’t been solved for over 5 years now.

However, here’s a workaround (to prevent others from going crazy):

Instead of trying `deck:current (` or `deck:current "("` you can use the regular expression escape sequence for hex character codes `\x`. Round brackets have the ASCII character codes `\x28` and `\x29`, respectively. Thus

`deck:current re:\x28`

will do the trick. Or, limited to a field: `deck:current myfield:re:\x28`. Of course you’re dealing with regexes now. If your search term contains special regex characters, you’ll get unexpected results.

PS: Neither using a character class `[(]` or trying to escape the bracket `\(` did work. It seems that all expressions with unmatched brackets fail. In my opinion a working parser for search terms is essential and should be fixed before implementing some other fancy feature.

PS2: Damien Elmes let me know that `"(" ` should work now. I tried that, but it only works with `deck:current "("`. If limited to a field `deck:current myfield:"("` it still doesn’t work.

---

<div class="post-metadata">

**Author:** ![Rumo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/rumo/32/1505_2.png) [@Rumo](https://forums.ankiweb.net/u/Rumo)\
**Post date:** [November 14, 2020, 5:11pm UTC](https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127/2 "2020-11-14T17:11:57Z")

</div>

`myfield:"("` does work, but

> […] searching on fields requires an ‘exact match’ by default.

You can use `myfield:"*(*"` instead.

I’m currently working on [overhauling the search syntax](https://forums.ankiweb.net/t/rethinking-ankis-search-syntax/4888). Since what you’re describing isn’t a bug, it won’t be changed, but if all goes well you’ll also have the option to escape parentheses with a `\` at some point.

However, if you find any other issue with the search syntax, please let me know.

---

<div class="post-metadata">

**Author:** ![joojanta](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@joojanta](https://forums.ankiweb.net/u/joojanta)\
**Post date:** [November 21, 2020, 7:24pm UTC](https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127/3 "2020-11-21T19:24:37Z")

</div>

Ah, I did not know about the exact match restriction in field searches. Good to know.

But not being able to escape brackets or search for brackets in regular expressions very much seems like a bug to me that begs for being fixed 🙃

---

<div class="post-metadata">

**Author:** ![Rumo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/rumo/32/1505_2.png) [@Rumo](https://forums.ankiweb.net/u/Rumo)\
**Post date:** [November 21, 2020, 8:05pm UTC](https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127/4 "2020-11-21T20:05:50Z")

</div>

You can by using double quotes, can’t you?  
However, by now my revision of the parser has been merged and in future releases, you’ll only be forced to use quotes if you want to match whitespace.

Edit: I have just realised that there is another case where quotes will be compulsory, namely when using unescaped parentheses in a RegEx (which is possible because Anki interprets it as raw input).

---

<div class="post-metadata">

**Author:** ![joojanta](https://avatars.discourse-cdn.com/v4/letter/j/b5e925/32.png) [@joojanta](https://forums.ankiweb.net/u/joojanta)\
**Post date:** [November 27, 2020, 5:23pm UTC](https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127/5 "2020-11-27T17:23:28Z")

</div>

Sorry, I could not find any regex that finds entries ending with a round bracket, for example.

I tried things like `deck:current myfield:re:".*\)"` or `deck:current myfield:re:".*[)]"` - none worked. The regex documentation doesn’t even mention how to escape special characters and the Anki manual is generally rather vague about the search syntax (especially about the handling of double quotes).

I do not have the time to do further bug searching, I’m afraid. Hoping future releases will bring relief.

---

<div class="post-metadata">

**Author:** ![Rumo](https://sea2.discourse-cdn.com/flex002/user_avatar/forums.ankiweb.net/rumo/32/1505_2.png) [@Rumo](https://forums.ankiweb.net/u/Rumo)\
**Post date:** [November 27, 2020, 8:52pm UTC](https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127/6 "2020-11-27T20:52:42Z")

</div>

> [@joojanta](#):
>
> I tried things like `deck:current myfield:re:".*\)"` or `deck:current myfield:re:".*[)]"`

Here, the problem is that the quotes have to enclose either the entire term or the part after the **first** colon. Both `"myfield:re:.*\)"` and `myfield:"re:.*\)"` will work. Maybe this case where there are two colons should be made more clear in the manual.

I totally agree about the lack of documentation concerning escape sequences. I’ve already made a PR which covers escaping in all cases and for every special character. It describes the behaviour of the new parser, though. I guess it won’t be merged before the next stable release.  
But it’s there on [GitHub](https://github.com/ankitects/anki-manual/blob/13ed58bba1eeb265fb17e975d072ed028c1e5461/searching.md) for everyone building from code or using the following betas.

* * *
Edit: It's already been merged and can be found in the [manual](https://docs.ankiweb.net/#/searching?id=matching-special-characters) now.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex002/uploads/anki2/original/1X/8f1279ababc5879d54e4838989f606cfe55af8c7.jpeg) [@system](https://forums.ankiweb.net/u/system)\
**Post date:** [May 1, 2023, 5:22am UTC](https://forums.ankiweb.net/t/workaround-for-finding-round-brackets-and/5127/7 "2023-05-01T05:22:02Z")

</div>


