Does anyone know if there is a way to use a wildcard in a switch statement?
I know in an if statement this is valid
str string = "whatever comes after whatever";
if (string like "whatever*")
{
info("Works");
}
but is it possible to do with with a switch? i haven't been able to find a good way to do it except for the following work around, which has a caveat.
str string = "whatever comes after whatever";
str startswithstring;
;
startswithstring = substr(string, 8, -8); //but what if you dont know the length of the string?
switch (startswithstring)
{
case "whatever" :
info("works");
break;
}
so its ok if you know the exact length of the string in which you want to search. but what if the string is of an unknown length? this workaround would only be good if you knew the length of the original string.
*This post is locked for comments
I have the same question (0)