Discussion (4)2
Log in or sign up to continue

The $LENGTH function can give you the number of PIECEs in a string, and the $PIECE function can grab multiple pieces, so for your example:

S DELIM="D"
S STRING="aaDtext1Dtext2"
W $PIECE(STRING,DELIM,1,($LENGTH(STRING,DELIM)-1))

Edit: Links to documentation for the $PIECE and $LENGTH functions:

$PIECE: https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_fpiece

$LENGTH: https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls?KEY=RCOS_flength

Hope this helps!

With more recent versions, yes. The user didn't state what version Ensemble was in use, so I figured offering a solution that would work as far back as Ensemble 2009 wouldn't necessarily be a bad thing. I still have to support Ensemble 2012 and I did test the *-1 functionality there, and in that version this functionality did not yet exist. (Actually, a few sites I support are still using Cache 5.x. It may be geriatric, but it keeps on plugging along... :-) )