How to Find Duplicate value in string array

Hello Folks,
It’s urgent can anyone help me? it will be a great help.
My question is how I can find duplicate value from my string array.
here I have attached screenshot of my array . in this screenshot have only three lines.

Thanks in advance,


Ankur

1 Like

I am not really sure what the string array is based on your screenshot? I’m also not sure what it is you want to do with duplicates?

If you want to get an array without any duplicates, you can do the following, where Split_Text is your original string array and new_Split_Text is a string array variable that will no longer have duplicates: Assign new_Split_Text = Split_Text.GroupBy(Function(x) x).Where(Function(y) y.Count() > 1).Select(Function(y) y.Key).ToArray()

1 Like

Hi Dave,
In this screenshot you can see “Billing Contact” only once . if i get two “Billing Contact” so i have to throw exception.
so, do you have any logic for that ?

Thanks
Ankur

Anything like this?

Cheers

This is just a single string, not a string array, correct? And you only want to search for specific duplicates, such as the word “Billing Contact”, correct? If that is correct, the following will work.

In an if activity:
Condition: YourString.IndexOf(“Billing Contact”) = YourString.LastIndexOf(“Billing Contact”)
True Side: (leave this blank)
False Side: throw exception: multiple billing contacts found

1 Like

Thanks Dave there are three line in there. I will try now this is string array

yes but in string

What is difference between string and string variable?

String Array and 3 line in there.

In your example I can not see an array. I can see 3 lines in single string.

1 Like

yes but when i check length so its show 3 line

@ankur1984 your screenshot is showing a single string (a string variable you have named ‘sample’). A string array is a collection of 1 or more strings. Each string can contain an infinite amount of characters/words

Thank Dave its work for me. In this condition i use Ture and false in message box so, its show me true Can you please explain this condition in details if its suites you.

Thanks
Ankur

Not clear what length check you refer to.

IndexOf(“Billing Contact”) is searching for the characters found between the parenthesis “Billing Contact” in the overall string. It searches from the beginning until it finds “Billing Contact”. Once it finds that word, it returns the exact position within the overall string where it was found (where the first character is 0 and each character is +1 after that, so the 100th character in the string would return the number 99).

LastIndexOf() is doing the exact same thing, except it searches for “Billing Contact” starting from the end of the string.

If the first index (aka IndexOf) and the last index (LastIndexOf) are exactly the same, that means it only found the word “Billing Contact” one time within the string.

Thank you very Much I appreciate your help. Can you please send me your LinkedIn Profile if you don’t mind.

Regards,
Ankur

Hi @J0ska Thank you very much for your time.

@Dave and @J0ska Any suggestion on this topic .

Continuing the discussion from Basic Knowledge:

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