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

Testing for an integer in java

Name: Anonymous 2007-04-19 19:54 ID:OeZSnxtN

I was just wondering if there was a simple and easy way to test if a string(single char string) is a number.

Maybe some method I do not know about, or maybe something like

if (string[1].equals(\\#))

Any thoughts?

Name: Anonymous 2007-04-20 6:55 ID:V9osOUg+

>>1
Check the docs on java.util.regex (the only useful part of the Java library, and still comes with a retarded interface), and use Perl-compatible regular expressions to check for:
/^\s*-?\d+\s*$/

For floating point numbers:
/^\s*-?(?:\.\d+|\d+)\s*$/

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