[ic] Regular Expressions in Conditionals

David Christensen david at endpoint.com
Tue Sep 29 01:27:30 UTC 2020


> On Sep 28, 2020, at 4:33 PM, mihai at airdelights.com wrote:
> 
> Hello,
> 
> I'm fairly new to working with Interchange and am running into a syntax issue.
> 
> The problem I am trying to solve is deciphering between tracking numbers from two different shipping companies, and displaying a different message depending on which company the tracking number belongs to. Each company has its own set of rules for how the tracking number is structured, so its fairly straightforward to use a regular expression in order to pick apart the number.
> 
> I am using the "if" ITL Tag in order to check the variable against the regular expression, but I am running into a comparison issue. The line is "[if tracking_number =~ /^[0-9]{12}$/]" and it should return true if the characters are between 0-9 and the number is 12 digits long. Is it possible to compare a variable to a regular expression in the "if" tag? If so, am I doing the regular expression comparison incorrectly?

Hi Mihai,

I suspect you’re just needing to specify *which* variable is getting compared against; try `[if scratch tracking_number =~ /…/]` to test the scratch variable in question.

HTH,

David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <https://www.interchangecommerce.org/pipermail/interchange-users/attachments/20200928/4ae3f0c5/attachment.sig>


More information about the interchange-users mailing list