Search code examples
regexdatabaseanalysismodelingalteryx

Regex_match in IF case


I want to make a Alteryx end-user prompt that will allow him to enter date into the data rows. The trick is that only first day of month is accepted in below format:

"mm/d/yyyy" (01/1/2017, 12/1/2018)

Unfortunately whenever I enter text, or other format (JAN-1-2016 etc) the warning prompt accepts it and enters the value into rows.

IsEmpty([#1])
or 
IIF(regex_match([#1],"(0[1-9]|1[0-2])\/([1-9]|[12]\d|3[01])\/[12]\d{3}"),1,0)

Solution

  • Ok, I modified the regexp and swapped 1 with 0 at the end of IIF. This will force end-user to enter only first day of month in one format: mm/d/yyyy

    IsEmpty([#1])
    or 
    IIF(regex_match([#1],"(0[1-9]|1[0-2])\/([1]|[12]\d|3[01])\/[12]\d{3}"),0,1)