How can I slice strings in Transforms?

#1

I want to slice one string in the canonical and map the parts to different fields on the type:

canonical:
A001
BB0001
BB000002

result:
field1: ‘A0’, ‘BB’, 'BB’
field2: ‘01’, ‘0001’, ‘000002’

What is the expression for slicing strings?

0 Likes

#2

To check available functions in expressions, please see ExpressionEngineFunction type.

In this case you’re probably looking for c3ShowFunc(ExpressionEngineFunction, “substring”)

0 Likes

#3

In this case, since I want to cut between [0:2] and [2:end], is there a special value for ‘end’?

Or do I have to check the length of the string like the following?
substring(myString, 0, 2)
substring(myString, 2, length(myString))

0 Likes

#4

Try it out, but i believe the 2nd. It might be a good feature request to have the ‘end’ parameter default to the string length

0 Likes