Add the ability to escape characters in filters

Issue #153 closed
Mikhail Lopatkin repo owner created an issue

There are some special characters in filters:

  1. PIDS, tags and app names use , as a separator. It isn’t possible to search for tag that contains a comma.
  2. It isn’t possible to search for pattern enclosed in /…/ if the filter supports regexes - the pattern is always interpreted as a regex.
  3. It isn’t obvious how to search for a numerical app name because numbers are interpreted as PIDs.

For (1) there is no workaround at all. For (2) there is a workaround - just use regex quotation: /\Q/pattern-with-slashes/\E//For (3) there is a simple workaround - just wrap app name with regex: /1234/, it will be interpreted as an app name.

This also interacts badly with quick filters. For (1), if the tag contains , then the quick filter for it can be created but not edited.

Comments (5)

  1. Mikhail Lopatkin reporter

    One possible approach to solve (1) is to use existing /.../ to wrap commas. I don’t particularly like this idea because lots of things have to be escaped. I incline to use a separate syntax for “verbatim strings”, e. g. use backticks for this: `verbatim, pattern`. However, not-splitting regexes by commas is right thing to do as well. We can use usual escaping approach with prepending backslash \ to slash and backtick inside regex and verbatim string respectively.

  2. Mikhail Lopatkin reporter

    Well, not splitting regexes at commas is backward-incompatible: imagine /foo,bar/. It was previously split as /foo and bar/ but with the proposed change it won’t be split. So instead I decided to do BAT/CSV-like approach of escaping by doubling a character and drive it a little bit further:

    • To add comma in pattern just double it split("foo,,bar”){"foo,bar”}
    • Use backticks to include surrounding whitespaces, commas, etc - only applies for plaintext: split(` foo,bar `){“ foo,bar ”)

    Lots of escaping in regular expressions, though, because backticks are reserved for making pattern plaintext.

  3. Log in to comment