How to remove duplicates from string variable

Hi All,

Input:

IR21 Airtel_NERCT _09 May_2024.pdf - PDF unstructured, please handle manually
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_BIHMS_2025-01-13.pdf - OK
IR21_DOMCL_2025-01-14.pdf - OK
IR21_DOMCL_2025-01-14.pdf - OK
IR21_DOMCL_2025-01-14.pdf - OK

Output:

IR21 Airtel_NERCT _09 May_2024.pdf - PDF unstructured, please handle manually
IR21_BIHMS_2025-01-13.pdf - OK
IR21_DOMCL_2025-01-14.pdf - OK

Thanks
Shaik

Hi @shaik.muktharvalli1

You can use the below expression to remove the duplicates from String variable, Store the input string in a variable called InputVar

- Assign -> OutputVar = String.Join(Environment.NewLine, Input.Split(Environment.NewLine.ToCharArray).Distinct)

Check the below workflow,

Hope it helps!!

1 Like

still same issue

In mail body getting duplicates lines have to remove before sending them

please help

thanks
shaik

Can you share the proper input to me… @shaik.muktharvalli1

your query is quite confusing, could you be more specific…

@shaik.muktharvalli1,

Use this code:

Code xaml:
Test.xaml (8.7 KB)

Output:

1 Like

This is the most easiest way to remove duplicates from string. @shaik.muktharvalli1

  1. Assign variable as string.
    Note - your string will be set as one liner
    example - ABC,PQR,LMN,PQR.
  2. Than use this string.join method in UiPath to remove duplicates.
    String.Join(“,”,Input.split(","c).Distinct()) for this also variable type as string.
    will give you output as
    Example ABC,PQR,LMN
    Hope this resolve your issue cheers and happy automation.