There are more than one ways to do this, but before I jump into explaining, can you confirm that your string can have max 2 occurrences of | and you have to get rid of the string after second | or can there be multiple occurrences of pipe and you have to get rid of every third string?
eg can your string be: GB|0923774|385763|GB|4523223|7873234
and desired output is: GB|0923774|GB|4523223
or will it always be only like: GB|0923774|385763 requiring output to be
Using with string:tokenize(input yourstring,delim= | returns ValueList),using map steps you can use valuelist[0,1] indexes or loop it and append them to a newstringlist and finally use string:makeString(input newstringlist,delim = |) to form GB|0923774
This logic should work with both of your cases when input is GB|0923774|385763 or GB|0923774…
Sorry Rob,i didnt see your post before my post which has similar suggestion and later realized.
Write a Java service that has the same service signature as pub.string:tokenize but name it something like myutils.string:split (put it into whichever folder makes most sense for your general purpose utilities).
Within the service, use String.split to perform the work (requires JVM 1.4 or later).