string - How to extract a substring depending on a specified char using Groovy -


i need extract part of name of folder. have code each of folders

import groovy.io.filetype def dirs = [] def currentdir = new file('c:\\compilationstaging') currentdir.eachfile filetype.directories, {     dirs.add( 'c:\\compilationstaging\\'+it.name)     println( it.name) } dirs.sort()  def list = dirs.reverse() 

this gets me list of folders, in specific format:

  • 2013.28.08.14.08.16_debug_value1

  • 2013.28.08.14.08.16_release_value2

  • 2013.28.08.14.18.36_debug_value3

i need each it.name last part of name (value1, value2, value3) thanks....

try

println( it.name.split( '_' )[ -1 ].tolowercase() ) 

Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -