Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
patricesoulet
Contributor
Contributor

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",""), ...
Labels (2)
9 Replies
Anonymous
Not applicable

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," ","")
patricesoulet
Contributor
Contributor
Author

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 :
patricesoulet
Contributor
Contributor
Author

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.
Anonymous
Not applicable

how to remove space in a string in tmap "
ex "   abc   def " to "abcdef"
Anonymous
Not applicable

columnName.replace(" ","")
Anonymous
Not applicable

or column.replaceAll(" ","") if you wanna get more aggressive 0683p000009MAB6.png
Anonymous
Not applicable

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.
Anonymous
Not applicable

ah, I was not aware of the difference. thanks!
Anonymous
Not applicable

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 0683p000009MACn.png