|
|
Subject:
write a set of regular expressions tha regconise dates
Category: Computers > Programming Asked by: kazami-ga List Price: $2.00 |
Posted:
03 May 2003 18:11 PDT
Expires: 02 Jun 2003 18:11 PDT Question ID: 199033 |
write a set of regular expressions tha regconise dates in normal text. eg 12th February 2002, is a date, so is 03/02/2002, and so is 4 Mar'02. there are a lot of different ways dates can be recognised. And use the egrep in linux | |
| |
|
|
Subject:
Re: write a set of regular expressions that recognise dates
Answered By: coral-ga on 04 May 2003 22:06 PDT |
Here you go. Tested compatible with egrep 2.5.1; it's too bad you aren't using Perl, or this would look somewhat more readable :) Were you aware there's perl modules to handle this? I'm available for further work on this regex, if you'd like to understand it more fully or improve it to support other dates; if interested, you should ask a new question, referencing this question. - R. ((0?[1-9]|[1-2][0-9]|3[0-1])(st|nd|rd|th)? +(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)[' ]+(19|20)?[0-9][0-9]|(0?[1-9]|1[0-2])[-/](0?[1-9]|[1-2][0-9]|3[0-1])[-/](19|20)?[0-9][0-9]|(0?[1-9]|[1-2][0-9]|3[0-1])[-/]([0-2][0-9]|3[0-1])[-/](19|20)?[0-9][0-9]|(0?[1-9]|[1-2][0-9]|3[0-1])([0-2][0-9]|3[0-1])(19|20)[0-9][0-9]|(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(ember)?) +(0?[1-9]|[1-2][0-9]|3[0-1])(st|nd|rd|th)?(,)? +(19|20)[0-9][0-9]) |
|
Subject:
Re: write a set of regular expressions tha regconise dates
From: coral-ga on 04 May 2003 22:08 PDT |
Hrm. Google wrapped it at the space characters, which breaks the regex. I've posted a copy of it at http://www.crystalflame.net/ga-199033/regex.txt in case it was corrupted by the web form here. Usage: egrep "..." *.txt # replace ... with the regex. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |