I guess it depends on the format of the dates, but in general the answer probably varies from "not easily" to "not without hideously overcomplex patterns you would never want to use in real life". It's probably a mistake to try to do this with just a regex. (This is probably good general advice for rexexes - don't insist on doing everything in one expression.) I'd probably use a simple regex just to locate any data-like pattern, and then parse it with SimpleDateFormat and decide if it's within the desired range. If not, call matcher.find() again to locate the next data. Repeat as necessary.
"I'm not back." - Bill Harding, Twister
Joined: Jul 11, 2002
Jim, Thanks for your help! My application is very complicated. It enables the users to search for a specific error with date range from different date format log files. For example, "Error 20089" and from "11/15/2002" to "01/27/2003". So your suggestion is that to search each date in each date format separately, right?
Joined: Jan 30, 2000
Um, maybe. What I meant was to search for any date, and see if it's in the desired range. It sounds like you might be thinking (a) create a list of all eligible dates, then (b) for each date, search for that date in the log file. That sounds pretty inefficient I think. If you've got a 1-year range and a 1-MB log file to search, I wouldn't want to search it 365 times for different strings. But I guess it would be best to continue this here so as not to fragment this discussion unnecessarily.