How to search for a character in a variable type array of string?

Further details:

variable: arr_MyArrayOfStrings(“My",“email”,“is”,"rpa_developer@uipath.com”)

I want the index of the place in the array that contains an @.

I don’t want to use a “for each” activity to cycle for every element in the array. I can’t use RegEx builder.

So the final and very excpecific question is:

Is there any array method that can search for a character in an array of strings? Something like IndexOf that can be used for arrays and not only for strings.

@Pelayo_Celaya_Fernandez

Try this

arr_MyArrayOfStrings.Where(function(x) Not x.IndexOf("@").Equals(-1))(0)

Assumption we have atleast one string which contains @

cheers

1 Like

@Pelayo_Celaya_Fernandez

arr_MyArrayOfStrings.ToList().FindIndex(Function(s) s.Contains(“@”))

1 Like

Hi @Pelayo_Celaya_Fernandez

  1. Use the below condition in Assign activity
arr_MyArrayOfStrings= {"My", "email", "is", "rpa_developer@uipath.com"}

DataType of arr_MyArrayOfStrings: Array(System.String)

  1. Use the below condition in Assign activity
indexWithAt=Array.FindIndex(arr_MyArrayOfStrings, Function(item) item.Contains("@"))

DataType of indexWithAt: System.Int32

  1. Print it in Message Box

Hope it helps!!

1 Like

Edited 1.1: appended ToArray at the end

arrIndexes | int32 Array =

Enumerable.Range(0,arrValues.Length).Where(Function (x) arrValues(x).Contains("@")).DefaultIfEmpty(-1).ToArray()

it will check for all Items containing an @ and will retrun similar to other implementations (e.g. IndexOf) -1, if no item is matching the condition

1 Like

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