May-26-2022, 11:39 PM
(This post was last modified: May-26-2022, 11:40 PM by Pedroski55.)
I don't know, but I suspect, behind the scenes, within isnumeric(), re is being used anyway.
Is there another, better way to find numbers?
Why not just use re explicitly? Then you can see exactly what is going on.
Is there another, better way to find numbers?
Why not just use re explicitly? Then you can see exactly what is going on.
import re things = [1.5, '2.5', 3.5, '4.5', 'a.bc', 'cde. do', 2, 7, '2.A', '2.2.', '2.A2', 1.56, 2.77, '3.33.33'] my_pattern = re.compile("\d+\.\d+") for t in things: match_f = re.search(my_pattern, str(t)) print(t, match_f)And with the output of match_f.span() you can slice the number from a string!