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
    @mschmitt nice catch on the newline. Your solution looks great, the only thing I can think of that could be might need to be tweaked is if @srinivasm needs to retain consecutive newlines in the middle of the string. Rejoining the split array on char(10) will only add single newlines, so something like
    "a

    b"
    will change to
    "a
    b".
    Also I believe joinarray ignores empty strings, so removing nulls may not be required.
Reply
  • 0
    Certified Lead Developer
    @mschmitt nice catch on the newline. Your solution looks great, the only thing I can think of that could be might need to be tweaked is if @srinivasm needs to retain consecutive newlines in the middle of the string. Rejoining the split array on char(10) will only add single newlines, so something like
    "a

    b"
    will change to
    "a
    b".
    Also I believe joinarray ignores empty strings, so removing nulls may not be required.
Children
No Data