Switch case with string contains

how can we use switch condition in string.contains case
like i have 5 types of string
1 ab
2 cd
3 de

not neccesary in same position

then i need to split the string n find the one digit depends on scenario

I am getting the string from regex

Hi @Sakshi_Jain
You can’t use switch as for string.contains element.
Switch is used only with a constant string (= exactly case(ab) or exactly case(ba) and so on).
You have several choices:

  • either you use switch case with all possible combinations (so 10 cases)
  • or you replace the switch by 5 imbricated if/else with conditions if string.contains(a) and string.contains(b), and so on
  • or you replace the switch by 5 flowdecisions if/else with conditions if string.contains(a) and string.contains(b), and so on