Search code examples
elasticsearchkibanaelasticsearch-painless

Splitting a String at Char in Painless Scripting Language


I am trying to split a String (that represents an IPv4 address) in painless. I tried the following:

String[] ipAddressParts = /\\./.split(params.ip);

But the String doesn't get split at all.


Solution

  • You're almost there, the correct code is this one (you have one too many backslashes):

    String[] ipAddressParts = /\./.split(params.ip);