How to remove extra space captured by The Get Text Activity

Hi UiPath Lovers!

I need to extract Tax ID as shown in picture 1 and I using the command that is shown in picture 2. However, during extraction an extra space is fetch as shown in picture 3. Can anyone suggest how to remove extra space.

Picture 1

Picture 2


ClientInformation.Substring(ClientInformation.IndexOf(“TaxID:”)+“TaxID:”.Length).Split(Environment.NewLine.ToCharArray)(0)

Picture 3

Regards and Much Love
Jasmine

Hello Jasmine,

You’re looking for the Trim method. You can then give it something like " Hello world " and get “Hello world” back without the leading or trailing space characters.’

Conversely, you can try to remove the space character when you’re selecting the Tax ID.

1 Like

Thanks @dmccammond

Can plz advice how exactly trim method can be used in the following command.

ClientInformation.Substring(ClientInformation.IndexOf(“TaxID:”)+“TaxID:”.Length).Split(Environment.NewLine.ToCharArray)(0)

At that point, I wouldn’t use the Trim method. I would instead change how you are selecting. You can add the space that you’re trying to get rid of. Your code would look like this:

ClientInformation.Substring(ClientInformation.IndexOf(“TaxID:”)+“TaxID: ”.Length).Split(Environment.NewLine.ToCharArray)(0)

However, you may want to look at Regex as that would be a much cleaner way of pulling out that information. If you just want something that works for right now, what I gave above should do.

1 Like

Thanks alot @dmccammond and @lakshman for helping me to resolve this issue! Cheers

2 Likes

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