Top.Mail.Ru
March 24th, 2004 - Java developers — LiveJournal
? ?

Java developers

March 24th, 2004
Image

11:16 am - Imaget3knomanser - 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?
Image

04:33 pm - Imagedeltoideus - JTextComponent & ä, ö, ü, õ

Maybe a stupid question, but anyway:

Is it possible to insert strings containing letters ä, ö, ü, õ into JTextComponent?
Does anyone know the solution for this kind of problem?

ThanX.
Image

10:16 pm - Imageclemenceau - kthx.

I'd like to use the gamma function, but I've no idea how to do it because I don't know how to:
  • declare a variable that is approximately Euler's constant (e).
  • write the syntax for indefinite/definite integrals.
If this stuff isn't covered in the Math class, then I won't use it because it'd be too much work than it'd be worth for computing factorials of small numbers--but the can of worms opened by these functions has made me curious how to use calculus in Java.

Thanks ahead of time.
Powered by LiveJournal.com
Image