Results 1 to 2 of 2
  1. #1
    AlexMorris is offline Member
    Join Date
    Nov 2012
    Rep Power

    Default Having trouble with Pattern Matching

    Not sure where this is supposed to go.
    I have been having problems working out how to pattern match dates from some headers.

    I have been getting the body of a webpage and extracting the links so I get some urls which I am then going to use to get a head request for each. Then I am going to take the part of the head request that says when the webpage was last updated and return that. Problem is I am pretty sure the following pattern match on dates like the following [Last-Modified: Sun, 04 Nov 2012 20:59:59 GMT] is horribly wrong.

    Java Code:
    Pattern pdate = Pattern.compile("Last-Modified:(.*?)GMT");
    Matcher mdate = p.matcher(information);
    			ArrayList<String> Dates = new ArrayList<String>();
    			while (mdate.find()) {
    				String dates =;
    Can anyone give me a better pattern match / correct my code? I would also be incredibly grateful if you would point out any potential problems that you spot.

  2. #2
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Rep Power

    Default Re: Having trouble with Pattern Matching

    Well, according to my regex viewer, it does work. Perhaps the problem isn't in the regex itself, but maybe your input?

    Having trouble with Pattern Matching-screen-shot-2012-11-20-3.43.20-pm.png

Similar Threads

  1. Pattern for matching parts of url
    By joan.balaguero in forum New To Java
    Replies: 1
    Last Post: 05-10-2012, 02:52 AM
  2. Please Help me regarding String pattern matching
    By theyoung in forum New To Java
    Replies: 11
    Last Post: 11-08-2011, 02:59 AM
  3. A Question Regarding Pattern Matching
    By hadi in forum Advanced Java
    Replies: 4
    Last Post: 01-21-2011, 03:38 PM
  4. String matching a pattern
    By vividcooper in forum New To Java
    Replies: 7
    Last Post: 01-07-2010, 10:30 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts