This source from the Grafana forum said that Grafana uses the golang regex flavor.
I'm trying to extract a key value pair from the format:
(Foobar -- 48)
After following the Grafana doc on Extracting fields, it works with:
/\((?<key>Foobar) -- (?<value>\d+)\)/
But it doesn't work without the leading and trailing /
when I try it on Regex101 (using the Golang flavor). It works if I drop /.../
, or change it to JavaScript flavor.
So my question is what flavor of regex does Grafana really use? If it is using RE2, why the /.../
is required?
Grafana uses two regex engines in different places.
For everything happening on the client side JS engine is used. Almost everything that is related to Dashboard/Panel editing is done in client. So following actions
Please, note that in most cases Grafana doesn't evaluate queries and only passes them to the data source. So specifically for queries flavour of regex will depend on the data source itself.
For actions taking place on the backend Golang/RE2 engine is used. Places where you might encounter this flavour:
reReplaceAll
, match
)Additionally, I would like to note that in some input parameters might look like regex, but aren't one. For example, permitted_provisioning_paths
accepts |
-delimited lists, but those are just manually split into list.