Date Regular Expression in UNIX
NickName:user3317828 Ask DateTime:2014-03-03T07:43:20

Date Regular Expression in UNIX

I'm trying to write a regular expression to validate a date in Unix. The regex that matches a date in the usual format is mm/dd/yy

For example, it should match 03/20/98 or 11/08/89 but not 13/40/99

I managed to find the answer on Regular Expression to match valid dates but the expression is not working on UNIX.

Below regex is not working when I tried to validate the date

echo '12/01/2014' | grep '^((((0[13578])|([13578])|(1[02]))/)|(((0[469])|([469])|(11))/)|((2|02)/))[/]\d{4}$|^\d{4}$'

No matches

echo '2/1/2014' | grep '^((((0[13578])|([13578])|(1[02]))/)|(((0[469])|([469])|(11))/)|((2|02)/))[/]\d{4}$|^\d{4}$'

No matches

Copyright Notice:Content Author:「user3317828」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/22135276/date-regular-expression-in-unix

More about “Date Regular Expression in UNIX” related questions

Date Regular Expression in UNIX

I'm trying to write a regular expression to validate a date in Unix. The regex that matches a date in the usual format is mm/dd/yy For example, it should match 03/20/98 or 11/08/89 but not 13/40...

Show Detail

Unix regular expression

I need to use unix regular expression in unix find command: find "/home/user/somePath/" -maxdepth 1 ! -regex "/home/user/somePath/someUnwantedPath" ! -regex "/home/user/somePath/

Show Detail

Unix regular expression begginers question

I'm starting the study of regular expressions and I've been wondering how can I build and test the regular expression in UNIX notation for all vowel strings that contain the substring "ai&quot...

Show Detail

Regular expression to extract everything between braces in unix

I am trying to extract everything between braces from a text file and write the output to another text file. I was able to construct a regular expression to match everything between {} and it works...

Show Detail

What is the most correct regular expression for a UNIX file path?

What is the most correct regular expression (regex) for a UNIX file path? For example, to detect something like this: /usr/lib/libgccpp.so.1.0.2 It's pretty easy to make a regular expression tha...

Show Detail

Basic UNIX regular expression in python

I'm trying to use the re.match() method to check if my string looks like the regular expression. In UNIX on the cmd line I'd use "*,*" to check against a string such as, hello,there. The follow...

Show Detail

Extended Regular Expression in UNIX

I don't mean that this question for UNIX only, but I work on Solaris, and I didn't try it on any other OS. I confused between the extended regular expression: first: [[ "str" == ?(str|STR) ]] &am...

Show Detail

How to write a C program for Unix that can process the Regular Expression ?

I want creat a C program for Unix that can porcess the Regular Expression,like a simple Perl interpreter. Do I have to personally write an regexp engine?

Show Detail

Regular expression validation for date

In my asp.net application , i wants to enter date in the format DD-MM-YYYY where the entered date should be from today's date up to 6months..other wise it should shows an error message. What will b...

Show Detail

Date Regular Expression Django

What is the regular expression for date "January 22, 1955, 1:20 am" in Django? What's good resource for commonly used regular expressions like dates and others?

Show Detail