cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Regular Expression with Workato Lookup Table

hendrykurnia
Deputy Chef II
Deputy Chef II

Hi guys,

I have a use case where I use regular expression to validate the input of postal code.

E.g. Formula = "95000-2707".match?(/(^\d{5}$)|(^\d{5}-\d{4}$)/) for matching the US postal codes.

However, this method won't work if the regular expression is stored in a lookup able.

E.g. "regular_expression" lookup table

countryregex
United States/(^\d{5}$)|(^\d{5}-\d{4}$)/

Formula = "95000-2707".match?(lookup("regular_expression", "country": "United States")["regex"])

I have also tried the following formula but no luck.

"95000-2707".match?(lookup("regular_expression", "country": "United States")["regex"].to_s)

- "95000-2707".match?(/lookup("regular_expression", "country": "United States")["regex"]/) and "95000-2707".match?(/lookup("regular_expression", "country": "United States")["regex"].to_s/) with the following lookup table

countryregex
United States(^\d{5}$)|(^\d{5}-\d{4}$)

Thank you

1 ACCEPTED SOLUTION

hendrykurnia
Deputy Chef II
Deputy Chef II

Thanks Gary.

I would like to share what I have found. Actually, removing the '/' at the beginning and end of the regex in formula syntax and lookup table works.

countryregex
United States(^\d{5}$)|(^\d{5}-\d{4}$)

"95000-2707".match?(lookup("regular_expression", "country": "United States")["regex"])

Give it a shot

View solution in original post

5 REPLIES 5

gary1
Executive Chef III
Executive Chef III

Well, that's a whole lot easier! You know, when I was working on the script, I also had to remove the '/' at the beginning and end to get it to work, but I didn't think to double back and check if that would work with Ruby! Glad it's all working now.