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.
Anil_G
(Anil Gorthi)
August 4, 2023, 1:28pm
2
@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
rlgandu
(Rajyalakshmi Gandu)
August 4, 2023, 1:45pm
3
@Pelayo_Celaya_Fernandez
arr_MyArrayOfStrings.ToList().FindIndex(Function(s) s.Contains(“@”))
1 Like
Parvathy
(PS Parvathy)
August 4, 2023, 2:25pm
4
Hi @Pelayo_Celaya_Fernandez
Use the below condition in Assign activity
arr_MyArrayOfStrings= {"My", "email", "is", "rpa_developer@uipath.com"}
DataType of arr_MyArrayOfStrings: Array(System.String)
Use the below condition in Assign activity
indexWithAt=Array.FindIndex(arr_MyArrayOfStrings, Function(item) item.Contains("@"))
DataType of indexWithAt: System.Int32
Print it in Message Box
Hope it helps!!
1 Like
ppr
(Peter Preuss)
August 4, 2023, 3:15pm
5
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
system
(system)
Closed
August 7, 2023, 3:16pm
6
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.