Conditional month & year



I have to check if users have entered the date correctly in a file. The format should be like ‘MMM-YY’ like ‘FEB-17’ including the inverted comas.

the following will be incorrect:
FEB-17 <- Missing inverted comas
’Feb-17’ <- Not capitalised
’FEB 17’ <- Missing dash in the middle
’FEB-2017’ <- Year should be 2 digits

Is there an easy way to validate data entry?



Hi @selrac,

Kindly check my example attached:

Main.xaml (6.7 KB)


Thanks for your message. This produces the output I need, but what I need to do is to validate that the users have entered the the month/year in the form that I need it



First, you could also check if another string contains the entire string you need, for example:

var stringValidate = "'FEB-17'";
var stringFileName = "'FEB-17'.txt";
If  (stringFileName.Contains(stringValidate))

Secondly, I would suggest you to create a custom regex in order to validate if a specific string contains what you are expecting and use the Matches activity in order to get the result. You could use the following website to create and test a custom regex string:


If I understand correctly, you are suggesting to create a kind of a vlookup with the text file containing all possible options. That could work and gives me something to work on.



For much conditions to satisfy plz look it once…

Please revert with the response…
SAMPLE_dATE.xaml (14.6 KB)


Thanks Sankar. It is a great piece of code!!!


I am agree with @acaciomelo solution and you should use the different conditions based on string contains operation on it returns Boolean value based on that you can validate and for more then 2 cases it is good approach to use “Switch case activity” instead of nested if.

Just for sample quick check reference for you, consider this way as well if possible:



You may use below way also:

strUserDate = “‘FEB-17’” ( added quotes)


boolDate = Regex.IsMatch(strUserDate,strRegex")


Hey @vvaidya

Slight modification:

strUserDate = “‘FEB-17’” //<" ’ FEB-17 ’ " > then this regex will work.


and for

strUserDate = "FEB-17"



Hey @aksh1yadav

I thought Mr @selrac wanted with Inverted commas, so I added the quotes to Regex.


yes but in the strUserdate there was no “quotes” with string so it will always return false in that case so just pointed out. :slight_smile:


Gotcha! I forgot to keep quotes. Thanks.



I can not figure out how to make your code work. I’ve put together a simple check flow, but I’m not managing to make it work. How do you do the Redex check? I’m attaching my xaml test

StringCheck.xaml (12.8 KB)

Workflow example for Compare PDF file

I managed to get it working. Find xaml attached if it helps someoneStringCheck.xaml (11.6 KB)


Hey For your reference - StringCheck.xaml (11.5 KB)

try this regex - “(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)-(\d{2})$”



Hi @aksh1yadav

do you have that flow?