Removing blank space from string


I have problem with removing blank space from my string - it is value as text: eg. 2 500,00 EUR
I used str.Replace(" “,”") but it does not do completely - my result is 2 500,00EUR.

How to remove space between numbers.


Using str.Replace(" ", [String].Empty) gives me the same result.

Hi @Krzysztof
Do Like This YourStringVariable.Replace(" “,”") Replace " " with “”(Null) Value.

1 Like

Hope this could help you
yourvariable.ToString.Replace(“ “,””).Replace(“EUR”,” EUR”)

Cheers @Krzysztof

1 Like

It does not work. I download xlsx table with data eg: 2 500,00 EUR, 125,50 EUR, 6 900,00 EUR. I have to sum it. In first step I cut 4 last signs - space and “EUR”. I use: str.Substring(0 , strWartoscEDK.Length-4)
I got str eg. 2 500,00 and I want to convert to double. I think that problem is with space between numbers.

Please find attached data table.datatable.xlsx (8.7 KB)

Hello @Krzysztof
Its working for Me Please Take a (7.9 KB)

1 Like

Hello @Krzysztof try below…

str = str.replace(chr(160),"")

Note: space chr between 2 and 500 is not a normal space… it is non breaking space… reference []

Update: If you want only numbers then try below…
str = System.Text.RegularExpressions.Regex.Replace(str,"[^0-9,]","").Replace(",",".")


Hi @Krzysztof

Please find below image. this character is a non breaking space. for this the ascii value is 160.
so you can use below code to replace.

In this kind of situations try to use Asc(Character). This will give you the ascii value which you can use in your code to perform any string operation.



1 Like

Please check my table. As I see there is not possible to remove space from these value.

datatable.xlsx (11.2 KB)

I used this solution

It works!

Thank you for your help!

That’s cool
Cheers @AkshaySandhu

If you use Regex you can replace all whitespace at once.
Import System.Text.RegularExpressions into your project from the imports tab and then do Regex.Replace(str,"\s","").

\s is a special Regex expression that matches all whitespace so it takes care of tabs, line breaks, spaces, nonbreaking spaces, etc.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.