Unable to trim space, while other symbols are trimmed

varSplit(2).ToString.Replace(" “,”").Replace(",","").Replace("-","").Trim

This changes the value of the variable from e.g. “1 622,-” to “1 622”

Have tried searching both this forum and google without finding any reason why space is the only char I’m not able to remobe from the variable.

This seems odd, so I’m not sure.
But, there are also alternative ways to remove characters.

the above example will remove all characters except numbers.


1 Like

Worked perfectly! If it is an int32 variable, will it work just as good if I drop the “.ToString”?

It needs to be a string for the Replace to work, but you can convert it back with Convert.ToInt32() or CInt()

1 Like

Thank you!

I’ve tried this and not getting what I expect.
So i’m reading a CSV and the variable name is CSVFundSelection1 and in that cell it has Emerging Markets (100). And what i’m wanting to do is remove everything but the 100.
This is what i put in the Assign:

Can you give me assistance?

Is CSVFunSelection1 the string that equals “Emerging Markets (100)”? And, what is the output you are getting after the assign activity?


I’m good now. Spoke too soon.

So now i have a new issue so the CSVFundSelection1 now has Emerging 2020 Markets (1188). So when i use the above expression i get 20201188. and all i need is 1188.
I have tried this and it doesn’t work:
CSVFundSelection1.Trim.ToString.Replace("(","" ).Replace(")", “”)

I’ve been able to remove the ( ) but all the text stays.

value=CSVFundSelection1.Split.ToString("(“c),You will get your value in value(1)
string = string.Replace(”)", “”)


browsers.xaml (5.5 KB)

I’m looking into it now. and trying to get this to work.

I would still suggest you use a Regex pattern. You can find out how to do the pattern with many examples and tutorials online.

Using the Split option works though, but I would normally do it like this:


So it takes the string after “(” and before “)”

The Regex solution would be like this:

System.Text.RegularExpression.Regex.Match(CSVFundSelection1, "(?<=\()(.*)(?=\))").Value
System.Text.RegularExpression.Regex.Match(CSVFundSelection1, "(?<=\()([0-9]{1,10})(?=\))").Value

So it simply pulls the string that is between ( ) or second one is pull it if only it’s digits 0-9
Also, get in the habit of storing this pattern in a variable or part of a config dictionary.


thanks. i will try this now. i appreciate your assistance.

I’ll also add that if you use the Split method, make sure you verify it contains a Parenthesis or it will throw an error. You can do this with an If activity or using If() inside the code, like my below example…

If(CSVFundSelection1.Contains("(") and CSVFundSelection1.Contains(")"), CSVFundSelection1.Split("("c)(1).Split(")"c)(0), "")

The Regex method does not need this though.


1 Like

This worked great. Thanks so much for your assistance.

OK. I have another csv question. So my cell has two values in it and the first part can vary but i know the end of the cell the last 11 digits i need to pull in one variable and the first part i can do a trim to end to get the empty spaces.
Here is what the cell looks like: