Basic questions…
I want to apply if condition
Possible string ->Teststring1 = New(dynamic name)*
Teststring2= New
Teststring3= New(dynamic name)
Teststring4 = Old
I want a if condition such that it will accept teststring2 or teststring3
For rest all values it goes to Else part.
If Teststring.StartsWith("New") AndAlso Not Teststring.StartsWith("New(")
Then
// Actions for Teststring2 and Teststring3
Else
// Actions for other cases
Teststrings= {"Teststring1 = New(dynamic name)*", "Teststring2= New", "Teststring3= New(dynamic name)", "Teststring4 = Old"}
For Each Teststring in Teststrings
If
(Teststring.StartsWith("Teststring2")) OrElse (Teststring.StartsWith("Teststring3"))
Then
Write Line-> "Teststring2 or Teststring3 detected."
Else
Write Line-> "Other cases detected."
End If
End For Each
Assuming your test strings are like the below:
Teststring1 = New(AAA)*
Teststring2 = New
Teststring3 = New(BBB)
Teststring4 = Old
Insert the following into your IF statement condition:
System.Text.RegularExpressions.Regex.IsMatch(INSERTxTESTxSTRING, “New$|New\(.+\)$”)
*Just replace the capital letters with your string variable.