Skip to Content (Press Enter)
OutSystems.com
Personal Edition
Community
Support
Training
Training
Online Training
Developer Schools
Boot Camps
Certifications
Tech Talks
Documentation
Documentation
Overview
ODC
O11
Forums
Forge
Get Involved
Get Involved
Jobs
Ideas
Members
Mentorship
User Groups
Platform
Platform
ODC
O11
Search in OutSystems
Log in
Get Started
Back to Forums
Gerry
6
Views
3
Comments
Trim does not trim CR/LF
Question
I've noticed that the TRIM() function does not trim CR/LFs from a string. There should be an option to specify additional characters to trim (like CR/LF). Does anyone have something that does this? TIA!
Justin James
MVP
I've noticed the same thing, and it is frustrating because the Trim() behavior in other systems is ALL "whitespace" which includes newline.
What you can do:
1. Use Regex_Replace to search for ^\n and \n$ (I may have that reversed, I'm tired) and replace them with ""
2. If Index(NewLine()) = 0, get Substr(1, Length(Value) - 1), if Index(NewLine()) = Length(Value - 1), get Substr(0, Length(Value - 1))
You may want to roll them into an "EnhancedTrim" Action set to a "function" to make life easier. :)
J.Ja
1 reply
06 Aug 2012
Show thread
Hide thread
Gerry
Justin James wrote
:
I've noticed the same thing, and it is frustrating because the Trim() behavior in other systems is ALL "whitespace" which includes newline.
What you can do:
1. Use Regex_Replace to search for ^\n and \n$ (I may have that reversed, I'm tired) and replace them with ""
2. If Index(NewLine()) = 0, get Substr(1, Length(Value) - 1), if Index(NewLine()) = Length(Value - 1), get Substr(0, Length(Value - 1))
You may want to roll them into an "EnhancedTrim" Action set to a "function" to make life easier. :)
J.Ja
Thanks.
Actually, the code is something like this:
To strip at beginning:
If Index(TrimmedText,NewLine()) = 0 then TrimmedText = Substr(TrimmedText,2,Length(TrimmedText)-1)
To strip at end:
If Index(TrimmedText,NewLine(),Length(TrimmedText)-1,True) = Length(TrimmedText) -2 then TrimmedText = Substr(TrimmedText,0,Length(TrimmedText)-2)
Put each in a loop.
(Need to remember that NewLine() is CHR(13) + CHR(10) and that accounts for 2 characters.)
Kiko Baltazar
Thanks
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
See the full guidelines
Loading...