Regex still doesn't work

Thank you for the new version. Unfortunately, the regex still does not work as it should.

Example: My Gmail always has a text fragment in the title: “(poczta) - Google Chrome”. So I’m trying to create a Gmail category with regex: “\(poczta).\-.Google.” This is compatible with regex/python: .

Unfortunately the ActivityWatch category does not work with this notation. Some other categories containing brackets were saved without the preceding “\” character. (although it should be) and it works surprisingly. This time, unfortunately, no version works (with and without “\”). I don’t understand what the rule is here?

Are you running the latest version of ActivityWatch? We had issues with backslashes a few releases ago.

Yes, that’s why I wrote that I am surprised that this problem still exists in the new version (v0.10.0).

Since each event can only have a single category, are you sure that this event is not being matched by some other rule too?

The priority of being selected has to do with the depth of the category, for example if you have one category in “Browser->Chrome” it will be chosen over a root category “poczta”

I double-checked - no other entry should conflict with this one.
Interestingly, when use only “(poczta)” as regex - it works. When use regex “(poczta) - Google Chrome” - doesn’t work. But I have for Web WhatsApp this regex “WhatsApp - Google Chrome” and it works.

I made a simple HTML page to test this:


Then a simple rule: \(test\)

However, when I opened the Activity page I get a 500 error and when inspecting the request the regex escape category shows up as:

[["Testing","regex escape"],{"type":"regex","regex":"\(test\\)"}]

So it looks like there has somehow been a double escaping for the second \ character. Not sure what’s going on here, but I’ll look into it.

Edit: Found the issue, looks like JavaScript string replace doesn’t work as I expected and only replaces the first occurrence. I’ll fix it so it’ll work in the next release.

Edit 2: Here’s the PR with the fix, it’ll be in the next release:


Interestingly, the notation “(mail)” works correctly (without using backslashes). It doesn’t work until I add something that follows the brackets, for example “(mail) - Google Chrome”. OK, I’ll wait for a fix and check it using backslashes. Thank you!