-1

Currently attempting to split a large string field into 3 smaller fields. The string delimited by a "/". Example String:

0123/ABCD1234/EFGH909883432212

At the moment I have managed to pull the middle section out using the following expression inside a variable:

$F{String}.split("/" ,5)[1].trim()

To be perfectly honest I am not sure how it works as I do not know what the 5 and 1 are for (which is probably what I need to know to get the other two sections)

Alex K
  • 22,315
  • 19
  • 108
  • 236
Dunny774
  • 74
  • 9

1 Answers1

0

After calling method spit an array is created holding substrings which are delimited by "/" in the original string. The trim removes any trailing spaces. Number 5 resembles optional parameter. An integer that specifies the number of splits, items after the split limit will not be included in the array.

Janis S.
  • 2,526
  • 22
  • 32
  • So I assume the for my case the 5 should be a 3?, How do I then identify I want to display the 1st, 2nd or 3rd section? – Dunny774 Aug 05 '16 at 11:14
  • 1
    The 5 is optional, you can omit that. It is resembling the count of how many of the split items your array will hold if there are more than the limit. You can specify which section you will display by using the array index which is 0 based, e.g, `split("/")[0]` would result in `"01234"` – Janis S. Aug 05 '16 at 11:22
  • 1
    Thank you, Now I know have got it to display the data correctly. – Dunny774 Aug 05 '16 at 12:10