Regexp literal escaping #2061
Labels
component/loki
keepalive
An issue or PR that will be kept alive and never marked as stale.
type/enhancement
Something existing could be improved
Is your feature request related to a problem? Please describe.
For filter expression and soon to come extract expression, regexp can be difficult to write. Because of the quoted string
{app="foo"} |= "\\w+"
the normal string escape rules (preceding special characters with \ when included in a string) are necessary. This causes regular expression to be converted.Describe the solution you'd like
Javascript has 2 ways of declaring regexp see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
Example:
As you can see the first one doesn't need escape.
So my suggestion is to support the two syntax:
{app="foo"} |= "\\w+"
{app="foo"} |= /\w+/
Describe alternatives you've considered
Do nothing and live with it, personally sometimes it a pain to prepare a regex in an online editor and then have to fiddle with it to make sure everything is escaped correctly.
Additional context
Here is a example that was difficult to build for this reason:
/cc @owen-d @slim-bean if we have consensus I could work on that.
The text was updated successfully, but these errors were encountered: