How do I split a text which is read from a JSON file?

Hi there, apologies if this is a dumb question, I’m quite new to UiPath still!

I have an issue where a value is being input into a database, but the full text isn’t required and so I need to split it. So, or example, we may have a customer name as:

“Steve Smith T/A Smith’s Hotdogs” - we only want ‘Smith’s Hotdogs’ in this instance.

I’ve input an If activity to say ‘if the customer name contains T/A…’

The problem is, I don’t know how to write the code, as it shows as follows:

iJsonObject(“CustomerName”).ToString

How would I change this to only include the text after the T/A (removing white spaces before and after also)?

Thanks for your help!

1 Like

Hey @dr1992

Please find the below…

iJsonObject(“CustomerName”).ToString.Split({"T/A"}, StringSplitOptions.RemoveEmptyEntries).Last

Hope this helps

Thanks
#nK

1 Like

grafik

Regex or Substring can also help

1 Like

Thank you for your help with this.

Just a thought also: if I add .ToLower to this, it will add everything in lower case, will it not? I just thought that if on the JSON it appears as ‘t/a’ rather than ‘T/A’ that it may not pick it up?

1 Like

Damn ppr, you always are around with these tips :smiley:

Hey @dr1992

Feel free to add .ToLower which helps for your scenario.

Also please make sure you use lower case inside split separator string.

Thanks
#nK

1 Like

@dr1992
For the case insensitive way we can think on:

var parts = Regex.Split(iJsonObject(“CustomerName”).ToString, "t/a", RegexOptions.IgnoreCase).Last()

grafik

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