Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (login required).

Delimited Strings

Piece() has additional features. Piece() can return a range of pieces, rather than a single piece. It can return pieces from the same string based on different delimiters. Piece() returns the empty string if there's an empty piece (nothing before the first delimiter, or two delimiters in a row).

println "using string: slice of pizza"
println "3rd piece = ", piece("slice of pizza", " ", 3)
println "1st and 2nd pieces = ", piece("slice of pizza", " ", 1, 2)
println "2nd piece by i = ", piece("slice of pizza", "i", 2)
println "2nd (empty) piece by z = ", piece("slice of pizza", "z", 2)
println "count of pieces = ", len("slice of pizza", " ")
address = "One Memorial Drive^Cambridge^MA^02142"
city = piece(address, "^", 2)
println "city = ", city
println "MA starts at position #", InStr(address, "^MA^")+1 ' one past ^
Copy code to clipboard
FeedbackOpens in a new window