• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regular Expression?

 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi! I have a question about Regular Expression:
How to perform range searches on Date?
Any help would be appreciated!
Thanks!
[ January 29, 2003: Message edited by: Amy Howard ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Amy Howard
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Jim Yingst
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Are we home yet? Wait, did we forget the tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic