Painless regex

Hi, Im trying to extract the "ABCD_123.123.123.123" part from an adress, can you help me figure it out?

ABCD_123.123.123.123_DD_FS

This is what I have tried, but it trows me an error at the beggining of the regex

def m = /^_DD_FS$/.matcher(doc['server'].value);
 if ( m.matches() ) {
    return m.group(1)
}

Hey @Incauto, are you seeing the following error?

 "Regexes are disabled. Set [script.painless.regex.enabled] to [true] in elasticsearch.yaml to allow them. Be careful though, regexes break out of Painless's protection against deep recursion and long loops.
1 Like

Thanks, I just have to add the line script . painless . regex . enabled to my elasticsearch.yml

1 Like