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
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))
MessageBox("Correct!");
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: http://regexr.com/
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.
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:
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