how would I trim a mix of newline and space characters from the beginning and en

how would I trim a mix of newline and space characters from the beginning and end of a text string? For example,
"
this is
a string

" becomes
"this is
a string"

OriginalPostID-174728

OriginalPostID-174728

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    I've come up with the following which seems to work:

    with(

    local!array: split(
    substitute(ri!text, char(13), ""),
    /* removing char(13)s first - newlines will ALWAYS have char(10) and SOMETIMES also char(13) */
    char(10)
    ),

    local!secondArray: remove(
    local!array,
    where(
    apply(
    rule!APN_isBlank(_),
    local!array
    )
    )
    ),

    trim(joinArray(local!secondArray, char(10)))
    )
Reply
  • 0
    Certified Lead Developer
    I've come up with the following which seems to work:

    with(

    local!array: split(
    substitute(ri!text, char(13), ""),
    /* removing char(13)s first - newlines will ALWAYS have char(10) and SOMETIMES also char(13) */
    char(10)
    ),

    local!secondArray: remove(
    local!array,
    where(
    apply(
    rule!APN_isBlank(_),
    local!array
    )
    )
    ),

    trim(joinArray(local!secondArray, char(10)))
    )
Children
No Data