How to get values starting with Z by excluding Z1.1 & Z8.0

I am looping the data in string input argument Var1 which has value (“Z22.21, Z3.7, Z1.1, Z8.0”) and i want to get all values starts with Z except Z1.1 & Z8.0. I want to exclude the values Z1.1 & Z8.0. I tried below IF condition but it didnt work. Can someone suggest how to use the condition?

If (currentItem.Contains(“Z”) And currentItem <> “Z1.1” And currentItem <> “Z8.0”)

Hi,

Did you use split method for the input string to pass ForEach?
For now, can you try the following condition using Trim?

 (currentItem.Contains("Z") AndAlso  currentItem.Trim <> "Z1.1" AndAlso currentItem.Trim <> "Z8.0")

Regards,

1 Like

At loop level we can rewrite
currentItem.Trim.StartsWith("Z") AndAlso Not {"Z1.1","Z8.0"}.Contains(currentItem.Trim)

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