regex help on parsing strings to dates

0
Hi, I need a hand with the a regex. I use a parsing service that parses a document and abstracts dates which are returned as a string. I use the following expression to parse the string: parseDateTime($InputString, 'dd-MM-yyyy') however sometimes a unparsable string is return (e.g. the string "heden" is often returned. Can anybody help me find/construct a regular expression that will allow only stings that can also be parsed with the expression above? thanks a lot hp
asked
4 answers
3

Instead of using a regular expression, you could use the parseDateTime variant that returns a default value if parsing fails, like this:

parseDateTime($inputString, 'dd-MM-yyyy', empty)

This will yield a date if parsing the string succeeds, and an empty value otherwise. Afterwards you can check if the value is empty to know whether parsing succeeded.

answered
1
^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[012])[- /.](19|20)\d\d$

from regexbuddy

answered
1

Note, that your question is not related to mendix. You can easily search on google. This one should work:

^(0[1-9]|[12][0-9]|3[01])[-](0[1-9]|1[012])[-](19|20)\d\d$

BTW: you can easily check your regex with: http://regexpal.com/

answered
0

regular expressions info

answered