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.
Code:
Pattern pdate = Pattern.compile("Last-Modified:(.*?)GMT");
Matcher mdate = p.matcher(information);
ArrayList<String> Dates = new ArrayList<String>();
while (mdate.find()) {
String dates = mdate.group(1).toString();
Dates.add(dates);
System.out.println(m.group(1));
}
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.
1 Attachment(s)
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?
Attachment 4246