If Array or List Contains name Remove

I’ve tried a few approaches including converting Array to List and Invoke Method - Remove, but I have been unable to generate the results I’m looking for.

Array data:

{Mr. Elmo Smith, Engineering Supervisor;
Ms. Lamb Chop, Production Systems
Mrs. Big Bird, Building Manager;
Barney Rubble, HMD Global}

1 - Mr. Elmo Smith, Engineering Supervisor;
2 - Ms. Lamb Chop, Production Systems
3 - Mrs. Big Bird, Building Manager
4 - Barney Rubble, HMD Global

If an index contains HMD Global - remove it from list/array

Split remaining elements to First and Last Name only
Convert to Last, First to search AD

Desired Results:
1 - Smith, Elmo
2 - Chop, Lamb
3 - Bird, Big

1 Like

Should be a simple approach.
Can you share/upload your xaml file. Need to see the extent you have reached so i can add a solution to it?

@RR2 If you do
for each and check and try to delete a record then the Indexing of the Collection is being Altered, you need to filter the list based on your condition but not to delete it, This approach is very much easier if you have it in a table.
Use The Contains Method in .Net for your list or array and filter it out.

Assuming you have your names in array(of string) named strArr

1/ You could filter out all elements containing “HMD” using
strArr = arrStr.Where(function(x) not x.Contains("HMD")).ToArray

2/ You could remove “Mr.” “Ms.” etc using
strArr = arrStr.Select(function(x) x.Replace("Mr. ", "")).ToArray

3/ You format name using string manipulations described in

Alternatively 2/ and 3/ could be achieved by regular expression.



You could write it as a Python script quite simply, if that option is available to you, just invoke it in your workflow

def parse_employees(array_in):

    for employee in array_in:
        if "HMD" in employee.split():

    names_only = []
    for employee in array_in:
        x = employee.split(", ")
        new_employee = x[0].replace("Mr. ", "").replace("Mrs. ", "").replace("Ms. ", "")

    final_list = sorted(names_only, key=lambda x: x.split(" ")[-1], reverse=True)

    return final_list

Hope these steps would help you resolve this
—let’s say we have the array stored in a variable named arr_value

—now use a assign activity like this
str_arrayvalue = String.Join(“”,arr_value).ToString

Where str_arrayvalue is a variable of type string
—now use a assign activity like this
arr_final = Split(str_arrayvalue,”;”)
Where arr_final is a variable of type array of string

—now use a FOR EACH activity where pass the arr_final variable as input
— inside the loop use a IF condition like this
Not item.ToString.Contains(“HMD Global”)

Use a writeline activity and mention like this

Split(Item.ToString,” “)(2).ToString.Trim+” “+Split(item.ToString,” “)(1)

Cheers @RR2

1 Like

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