Transformer trim question
Moderators: chulett, rschirm, roy
Transformer trim question
What happens when you trim('') as opposed to trim (' '), that is trim of a field without a space, and trim of a field with just a single space . I believe trim removes trailing and leading spaces, but what if i want to have just a single space intact? Will trimming remove the single space as well?
-
- Premium Member
- Posts: 1735
- Joined: Thu Mar 01, 2007 5:44 am
- Location: Troy, MI
Re: Transformer trim question
single space from where? between to words or leading or trailing?dscon9128 wrote:What happens when you trim('') as opposed to trim (' '), that is trim of a field without a space, and trim of a field with just a single space . I believe trim removes trailing and leading spaces, but what if i want to have just a single space intact? Will trimming remove the single space as well?
look for the different options of trim function (Basic Reference Guide), I think D and R are suitable options if you want only redundant characters to be removed.
Priyadarshi Kunal
Genius may have its limitations, but stupidity is not thus handicapped.![Wink :wink:](./images/smilies/icon_wink.gif)
Genius may have its limitations, but stupidity is not thus handicapped.
![Wink :wink:](./images/smilies/icon_wink.gif)
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
The default behaviour of Trim() is to remove leading, trailing and redundant consecutive trimmable characters. Therefore Trim(" ") would leave a single space character as the result.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Thanks a lot to both of you for your response. Basically , to restate my exact requirement, i need to trim all the fields on incoming data, before sending the data to an xml output stage. I achieve the trimming by means of using a transformer. However, some fields have a single space as the value.It is important that i maintain that single space,and hence i was just wondering if the trim function would eliminate the single space as well.ray.wurlod wrote:The default behaviour of Trim() is to remove leading, trailing and redundant consecutive trimmable characters. Therefore Trim(" ") would leave a single space character as the result. ...
So if i understand Ray's response , trim of a single space should preserve the space intact. i.e trim(" ") =" ".
Thanks again!
Uday