I\'m learning regex and I would like to use a regular expression in Python to define only integers - whole numbers but not decimals.
I could make one that only allow
You need to anchor the regex at the start and end of the string:
^[0-9]+$
Explanation:
^ # Start of string [0-9]+ # one or more digits 0-9 $ # End of string