How to get specific array valuebased on keyword from string array?

i have an array {“EMAIL_xxxx@gmail.com”,“Name_anisha”,“PhoneNumber_233434555”}
now i want to get the value which has Word “Name” in it
how can i achieve this?
HELP!!!

Hi
Hope this expression in assign activity would help you resolve this
If your array variable is named as arr_input

Then use a assign activity like this

str_output = arr_input.Where(Function(a) a.ToString.ToUpper.Contains(“NAME”))(0).ToString.Trim

Cheers @anishakotian400

1 Like

Use an assign acitvity
Left side: arrNames | DataType: String()
Right side: YourArray.Where(Function (x) x.StartsWith("Name")).toArray

feel free to modify the condition by other string methods e.g. contains, substring…

Depending on your Original array you can retrieve the value e.g. with arrNames.First() arrNames(IndexAsInt) and also you can check if there is a name within an if activtiy by the condition arrNames.Count > 0

@anishakotian400

You can use Contain / Start with for this

nameVariable = ArrayVariable.Where(Function(a) a.ToString.ToUpper.Contains(“NAME”))(0).ToString.Trim

nameVariable = ArrayVariable.Where(Function(a) a.ToString.StartsWith(“Name”))(0).ToString.Trim

Contains will search the elements of the Array whether it contains the Name in the element or not

Startswith is more specific and it will search only the elements which is starts with the Name

It purely depend your wish to choose

Thanks

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