Regex on painless Script fro trigger

Hi everyone,

someone allready try regex on trigger throufg painless script ?

int score = 0;

for (int i = 0; i < ctx.results[0].hits.hits.length; i++) 
{
  // searching for OutOfMemoryError JAVA error on exception to raise an alert
  if (ctx.results[0].hits.hits[i]._source.message =~ /*EXCEPTION*/) 
    {
        return true;
    }
}

Is it working by adding " script.painless.regex.enabled: true in elasticsearch.yml ?

https://www.elastic.co/guide/en/elasticsearch/painless/current/painless-walkthrough.html#modules-scripting-painless-regex