Switch Cases based on varible value found in regex

I’m trying to solve an issue where i need to do one of three activities based on a variables value that contains userinfo. As an example if the Variable contains Liam430D it goes trough one process, if it contains John093X it goes through another process and so forth. Should i make a regex for each? or is there a better way to solve this?

@GovPro
welcome to the forum

do start with exploring the switch activity

Hi @GovPro

Welcome To Community!

You can use Switch as suggested

You need to pass the string variable as option and the case names as Liam430D and so on.

But what i assume is the text you are saying are seems like names and you may not know all the names that to be given as cases in switch

Regards
Sudharsan

Im mostly interested in the this value Liam430D. since there are multiple people with the same. If the user is a person with 430D it goes one way. and if its 093X it goes another. if not either it goes a third way

If it is always 4 lettered means you can try this expression in the Switch Expression @GovPro

System.Text.RegularExpressions.Regex.Match(INputString,"\d+\D+$").Tostring

image

Then you can create the case as per you need

Regards
Sudharsan

1 Like

its always the 4 letters but i only need 430D for case 1 and always 093X for case 2

Yes with that expression you will get that string @GovPro

1 Like

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