Question
· Jun 25

How to remove line feed and carriage return from start and end, but not from the middle of a string

Hello,

Thanks for reading this question.

We need to remove the line feeds and carriage returns from start and end, but not from the middle of a string

We have tested the following ways:

set output = $ZStrip("[line feed](carriage return) str [line feed](carriage return) ing [line feed](carriage return)","<>C")

But it removes also control characters which we need to preserve...

Also we have tested:

set output = $REPLACE("[line feed](carriage return) str [line feed](carriage return) ing [line feed](carriage return)",$C(13,10),"")

But it deletes line feed and carriage return at the middle of the string, so it is not what we need...

How would you recommend us to implement it.

We have read:

https://community.intersystems.com/post/trimming

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

https://community.intersystems.com/post/zstrip-clean-string

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

 

Could you help us please?

Thanks.

Product version: IRIS 2020.1
Discussion (7)3
Log in or sign up to continue