Image

Java Regex (this _should_ work)

Okay, I'm writing a small page-scraping class. The page should be offering a set of digits between 0 and some value. I'm trying to pull those digits off and stuff them into a vector.

I bring the page into a string, that's no problem.

I then intialize my pattern like so:
String pattern = "(\\d*?)\\s";
Pattern p = Pattern.compile(pattern);
Matcher m = p.matcher(input);


What I'm trying to do is match "Any number of digits followed by a single whitespace character, but don't hold that whitespace character". Based on the source page, that's a safe regex. However, when I use this loop to stuff things in:
while (m.find()) {
	result.add(new Integer(m.group()));
}


I get a number format exception. When running the code through the debugger, m.group() is always returning an empty string. This makes me believe that it's my regex that's broken- except for the fact that m.find() returns true 585 times- when the source data only contains 500 numbers. I've also tried the pattern "\\d*?\\s", with the same result.

Thoughts?