Jonathan Anglin · Jun 18, 2020

Get count of substrings within a string

I have a code tag that performs some logic in a DTL, and want to add to it the ability to find the number of substrings delimited by a dollar sign ($) within a particular string. I have tried the following which compiles just fine, but generates an error when testing in the Data Transformation Builder.

set lineCount = $DCOUNT(reportBody,"$")

ERROR <Ens>ErrException: <SUBSCRIPT>zTransform+985^LH.IAMON.IAMONORU1XsformDTC2.1 *DCOUNT() Encoded subscript 1 > 511 bytes -- logged as '-' number - @' set lineCount = DCOUNT(reportBody,"$")'

1 0 3 275
Log in or sign up to continue
set lineCount = $Length(reportBody,"$")

should do the trick 

Yes, I just found that at the bottom of the $PIECE document. Thank you, Robert!

DCOUNT is a function of MV Basic. Not of ObjectScript !