Regexp as a variable in tick script

Hi,
I am trying to define a template script that uses a regular expression as part of the where clause. The following code works fine and filters out the data for the tags values that contain test.

var filter = /test/

var data = stream
|from()
.measurement(measurement)
.groupBy(groupBy)
.where(lambda: “server” =~ filter )

I am trying to convert this into a template tick script and populate jobs using json files. However I can’t get the filter var to work when it is defined in a json file.

Any ideas or pointers welcome.
thanks

To solve my problem I have implemented the StrContains function in my where clause. I pass a string from my json files to act as a substring. Not full regular expression as I wanted but enough to suit the requirements.

So my template tick script now looks like:

var filterstring string
var whereclause = lambda: strContains(“server”,filterstring)
var measurement ‘http_response’

var data = stream
|from()
.measurement(measurement)
.groupBy(groupBy)
.where(whereclause)

The JSON file to create the job looks like
{
“template-id”: “HTTP_response_time_alert_template”,
“dbrps”: [{“db”: “telegraf”,“rp”:“autogen”}],
“vars”: {
“filterstring”: {“type” : “string” , “value” : “https:” },
“crit”: {“type” : “float”, “value” : 0.200 },
“critreset”: {“type” : “float”, “value” : 0.200 },
“warn”: {“type” : “float”, “value” : 0.1 },
“warnreset”: {“type” : “float”, “value” : 0.1 }
}
}