One Star

Removing spaces from a string in java

Hello,
Anyone know how remove all spaces from a string in tMap with EREPLACE or with tReplace component ?
For example, if i have ' a3d fdj fdo fds fds &pp ', the result must be 'a3dfdjfdofdsfds&pp'.
I tried EREPLACE(string," ",""), EREPLACE(string,"\s",""), EREPLACE(string,"\\s",""), ...
9 REPLIES
One Star

Re: Removing spaces from a string in java

to remove beginning and trailing spaces:
StringHandling.TRIM(" hellow world! ")

EREPLACE worked for me (in TOS 3.0.0, see pics)
StringHandling.EREPLACE(row1.newColumn," ","")
One Star

Re: Removing spaces from a string in java

Yes, rigth, that work ... in this case ...
But when string is from an Excel file, where the cell is formatted as number with space for thousands seprator ... spaces aree not removed ...
My job :
One Star

Re: Removing spaces from a string in java

Finaly, i've find ... the thousands separator is not a space, but the hexa decimal caracter A0.
With StringHandling.EREPLACE(myString, "\\xA0",""), i can resolve my problem ...

Thanks for your help strpdsnk.
One Star

Re: Removing spaces from a string in java

how to remove space in a string in tmap "
ex "   abc   def " to "abcdef"
One Star

Re: Removing spaces from a string in java

columnName.replace(" ","")

Re: Removing spaces from a string in java

or column.replaceAll(" ","") if you wanna get more aggressive Smiley Tongue
One Star

Re: Removing spaces from a string in java

Both replace() and replaceAll() replaces all the occurrence found. However, there is difference in the type of arguments they accept.
replace() works on CharSequence, where as replaceAll(), accepts regex, so you can do a regular expression based pattern matching. The later is more flexible, but might result in a bit of performance overhead of compiling the regex and then do a matching.

Re: Removing spaces from a string in java

ah, I was not aware of the difference. thanks!
One Star

Re: Removing spaces from a string in java

Hi All,
Can any one tell me how to do this operation 
For example, change format of older data from ‘13960036’ to ‘1396    0036’
so its like '1396<<4 space>>0036'
 there are 4 spaces need to be added between the string
Please tell how i can do 
thanks Smiley Happy