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

Pages: 1-

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: ll 2007-11-27 2:39

Name: Anonymous 2007-11-27 5:10

Does `,' look like a digit to you?

Name: Anonymous 2007-11-27 5:12

\\s*+? What are you, stupid?

Name: Anonymous 2009-03-18 2:20

Don't call me gay, but I need some mary jay!

Marijuana MUST be legalized.

Name: Anonymous 2009-03-18 2:20

I wants lots and lots of some delectable pot!

Marijuana MUST be legalized.

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(",","");

Name: Anonymous 2009-03-18 2:31

>>7
Fixed a few silly things.
Pattern p = Pattern.compile("Results\\s+<b>(\\d+)</b>\\s+-\\s+<b>(\\d+)</b>\\s+of\\s+about\\s+<b>([\\d,]+)</b>\\s+for",Pattern.CASE_INSENSITIVE);
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(",",""));
}

Name: Anonymous 2009-03-18 2:33

>>8
Oh wait this is just some serious necroposting. Disregard that, I suck cocks etc..

Name: Anonymous 2010-12-27 6:54

Name: Anonymous 2013-01-18 23:03

/prog/ will be spammed continuously until further notice. we apologize for any inconvenience this may cause.

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