Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Suggested Answer
Replies
12 replies
Answers
2 answers
Subscribers
9 subscribers
Views
15951 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
AI and Rules
how would I trim a mix of newline and space characters from the beginning and en
srinivasm
over 9 years ago
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
Top Replies
Stewart Burchell
over 5 years ago
+1
Appian Employee
I would start by substituting all "new line" characters with a space; and then use trim() to remove all unnecessary spaces. So: fn!trim( fn!substitute( ri!myString, char( 10 ), " " ) …
Stewart Burchell
over 5 years ago
in reply to
Stewart Burchell
+1
Appian Employee
I just noticed the previous replies that reference use of char(13) alongside char(10)...so the principle remains the same, but you'd iterate over the string to substitute both with a space and then tidy…
Parents
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
@srinivasm: i've noticed also that trim() doesn't handle extra newlines. I would suggest perhaps devising custom functionality for this. The way I'd start out is to split the original string on the newline character - char(10) - then take that array and remove nulls. The remaining array members can be rejoined using joinArray(), where the separator is char(10) again; and then that result passed back through trim() to handle extra spaces on each line. This is off the top of my head so may require tweaking, but should get you close.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
Mike Schmitt
Certified Lead Developer
over 9 years ago
@srinivasm: i've noticed also that trim() doesn't handle extra newlines. I would suggest perhaps devising custom functionality for this. The way I'd start out is to split the original string on the newline character - char(10) - then take that array and remove nulls. The remaining array members can be rejoined using joinArray(), where the separator is char(10) again; and then that result passed back through trim() to handle extra spaces on each line. This is off the top of my head so may require tweaking, but should get you close.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data