Determine if a string is numeric: Difference between revisions

+ Python and Java
(→‎[[Perl]]: Created perl entry)
(+ Python and Java)
Line 70:
$string = '123';
if(is_numeric($string)) {
}
 
==[[Python]]==
s = '123'
try:
i = int(s)
# use i
except ValueError:
# s is not numeric
 
==[[Java]]==
String s = "123";
try {
int i = Integer.parseInt(s);
// use i
}
catch (Exception e) {
// s is not numeric
}
Anonymous user