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.
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()
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 ?
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
@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.
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.