How to use regular expression in Flow Switch?

studio
regex

#1

Hi,

I was wondering if i could use regex expression in flow Switch ?. For example the input string could be “User not found – Reg Error” or “Variable not found – App Error”. I want to have the same FlowNode that would work for both these strings. How can i make this work ?

Regards
Kiran


#2

Hi,

There are 2 ways I think.

  • You can just have 2 lines going to the same direction with both text
  • You can use either “NOT FOUND” or “ERROR” as your line then use an If condition inside the string condition for your switch. For example,
    If(text.ToUpper.Contains(“ERROR”) and text.ToUpper.Contains(“NOT FOUND”),“NOT FOUND”,text.ToUpper)

Regards.


#3

Hey Kiran,

Try this Use regular expression in Flow Switch.xaml (15.5 KB)

regex used

  • [A-Za-z0-9].*(- )(Regex Error)

  • [A-Za-z0-9].*(- )(App Error)
    further you can write a regex or use split function to extract the required text.

Hope it helps.

Regards,
Samnan


#4

I like your approach @MDSamnan, but I think it’s sometimes beneficial to use a Flow Switch activity rather than Decision in cases like this.
Here is an example of that: Use regular expression in Flow Switch.xaml (10.5 KB)

@kiran_kumar_sukumar

Regards