WMPublicStringTrim How it works Exactly

Hello Every body

Iam Currently Using WM:Public:String.trim function in our developemnt but the Strange thing is it trim frist and last spaces only what happend to the middle spaces. for Example Iam giving input to the string like “Raj kanth” my desire output is “Rajkanth” but it is coming as it is.
other than Java custom code any alternative Solution and One more question why trim is taking first and last spaces only.
Thanks in Advance
Regards
Sreekanth

Trim is designed to remove only leading and trailing white space. To remove all spaces you would need to use the pub.string:replace service to replace spaces with nothing. Thanks,

Tim

Thanks a lot Tim

trim also eliminates carriage returns or some hidden character that you normally can’t see on a text editor. useful when processing flat files or tokenizing stuff…

Yes, carriage returns, line feeds, tabs, form feeds and other chars are all considered “white space.”

Hi reamon,

So, I need your help. In my case, When I am generating a flatfile and is stored on some location. When I open it. the records are not aligned properly. I am using newline as new record. Can you please tell the solution to get the file records aligned properly.

Thanks,
David

Are you using a tab as a delimiter between fields? Typically, columns will not align in such files when viewing with a text editor.

You might try viewing the file using a spreadsheet. Each field should be in the proper column if the file is properly constructed.

No. My flatfile is a fixed length flatfile and I am using record parser as a newline.

In the schema, I have selected Demilter, Record parser newline, record starts at 0.

Please help.

You’ll want to select Fixed, not Delimited.

I have document- inside have StringList. while trimming i am not able to replace trimmed value with old value. Could you please help here.
Regards
Hariom

Hi Hariom,
Are you saying you want to trim the document/StringList for temporary use, but not actually change permanently? Can you clarify what is meant by “replace trimmed value with old value”?
Thanks,
Mary

Hi Mary Tillman,

I want to replace permanently from document.

Regards
Hariom

Hi Hariom,

To accomplish this with wM flow, you can loop over the document/stringList, invoking the pub.string:trim service, appending the output value from that to a new string list, and then (outside the loop) map the new string list to document/stringList.

A Java service is another option.

Thanks,
Mary

Hi,

when looping over the string list you can just map the output of the trim service back to the field from which you have mapped the input of the trim service.

Might be a task for a Map-Step with using the trim-service as a transformer inside the loop.
This avoids the building up of a new StringList, as addToList can become expensive depending on the size of the list.

Regards,
Holger