Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Regular expression syntax help

Name: Anonymous 2007-11-27 2:23

I'm using java, not by choice.  Anyway, I'm trying to parse HTML google results, specifically the total number of results from:

"Results 1 - 100 of about 5,533 for x"

If I make my regular expression <b>(\\d+)</b>, it returns the number 1, as it should.  If I make the expression \\s*+<b>(\\d+)</b>\\s* it also still works and finds the number 1, as it should.  Now I've tried about\\s*+<b>(\\d+)</b>\\s*+for which should return 5, but now it's not finding anything at all.  Where am I going wrong? (apart from having to use java in the first place)

Name: Anonymous 2009-03-18 2:29

>>1
Pattern p = Pattern.compile("Results\\s+<b>(\\d+)</b>\\s+-\\s+<b>(\\d+)</b>\\s+of\\s+about\\s+<b>([\\d,]+)</b>\\s+for");
matcher = p.matcher(googleTextResponse);
if(matcher.find()) {
   int start = Integer.parseInt(matcher.group(1));
   int end = Integer.parseInt(matcher.group(2));
   int numresults = Integer.parseInt((matcher.group(2)).replace(",","");

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List