Split string

Example:
/opt/apps/logs/engineering-ext/niwp/NiWpPerformance.log

i want to get the substring 'engineering-ext' & 'niwp', how can i get it in scripted field using painless.

You'll want use a regular expression for this. Something close to this should work:

def m = /opt\/apps\/logs\/([a-z\-]+)\/([a-z\-]+)\/.*/.matcher(doc['my_field_name'].value)

return m.group(1) + m.group(2)

See the Matcher docs for more information on how to use this class.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.