Remove empty space from tags and fields

Hello all,

In SAP Business Connector 4.6 I have tags and fields with
“surplus” of empty spaces which I want to remove. How I can
do that?
Number of empty spaces is dynamic. Tag names are dynamic.
example:
I have:

{name 1 } value 1 {/name1 }
{name 2 } {/name2 }

I would like to get

“{name 1}value 1{/name1}”
“{name 2}{/name 2}”

TIA

Gordan

Gordon,

Try pub.string:trim built-in service to trim spaces on both
ends. This may not help your situation since your tags are
dynamic though.

One thing I did for that is to convert your document to an XML string and parse it to remove the desired charaters. Once the necessary work is done reload it in your record.

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

Hi Sreekanth,

Without using a Java service , the alternate way is to create a flow service to remove spaces in the input string. The logic to be put is pretty simple. You find the length of the string and you start from the first character till last character.Unless and until you find a space keep pushing each character to a temporary output variable and if you find a space discard it.

Regards,
Somu

sreekanth: please don’t cross-post. It is unnecessary.

Sreekanth,
You can use the pub.string:replace service instead. search for “spaces” and replace by “nothing”.

This should work.

Shantanu