fork download
  1. class Ideone {
  2. static void main(String[] args) {
  3. String productPath = "Store/Grocery/Produce/Apples";
  4. productPath.split('/')[2, 3].each { // Zero-based index number. So third item is at index 2.
  5. println it
  6. }
  7. }
  8. }
  9.  
Success #stdin #stdout 2.18s 134624KB
stdin
Standard input is empty
stdout
Produce
Apples