How to use use Regular Expression (RegEx) within Azure logic app

14.2k Views Asked by At

I want to verify a value in my azure logic app which follows a pattern which can be identified by Regular Expressions.

My Value is KUL-M-X-Y, here KUL is fixed value but value of M can be "KG", "TON" etc., also Value of X and Y can be numeric.

I searched for RegEx related expression in Logic apps but didn't find any.

Can any one suggest possible way to work with this?

1

There are 1 best solutions below

1
TheTurkishDeveloper On

You can use inline code with Azure Logic Apps to handle regular expressions. I ran through the example and modified it to use the following regular expression:

/([K][U][L]-[a-zA-Z]{2,3}-\d\d)/g

You can then use a normal Condition step to check for existence of the results (if a match) or null if not:

enter image description here

Here is the code in the inline code step, for reference:

var reg = /([K][U][L]-[a-zA-Z]{2,3}-\d\d)/g;
var email = workflowContext.trigger.outputs.body.body;
return email.match(reg);