Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
OrganizationAdvent CalendarQiitadon (β)
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?


More than 5 years have passed since last update.


import re

def isd(N):
    return bool(re.compile("^[-+]?([0-9]+(\.[0-9]*)?|\.[0-9]+)([eE][-+]?[0-9]+)?$|nan$|^[-+]?inf$").match(N))

for i in ['-3.', '0.', '5..', '0.1', '1', '1e+2', 'b0', '0c', 'test','nan','1ee-3','1.3e-3','1.3e-3.','00.','5.0.','inf']:
    print('{0:9} {1}'.format(i,isd(i)))


-3.       True
0.        True
5..       False
0.1       True
1         True
1e+2      True
b0        False
0c        False
test      False
nan       True
1ee-3     False
1.3e-3    True
1.3e-3.   False
00.       True
5.0.      False
inf       True
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away