Trim issues

Hi Guys,

The var “Company_List” contains a list of companies, one of which is “Walgreens Boots Alliance”

Does .Trim not trim all whitespace, start/between/end ?
Company_List(8).ToLower.Trim.ToString

Output
walgreens boots alliance

I need without spaces
walgreensbootsalliance

I can modify the text but looking to do it with just string manipulation.

Thanks :grinning:

Trim only removes spaces at the beginning and end of the string.

If you want to remove all spaces…

Company_List(8).ToLower.Replace(" “,”")

Note that ToString isn’t necessary, because your list is list(of string) and so it already knows they’re strings. And in cases where ToString is necessary, it should come first before things like Trim and Replace.

2 Likes

Hey @MikeC ,

Use System.Text.RegularExpression.Regex.Replace(input,“\s+”,“”)

Thanks,
Sanjit

2 Likes

Works perfectly, thanks buddy :grinning:

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