For positive integers, use
r"(?<![-.])[0-9]+(?!.[0-9])"
Explanation:
(?<![-.]) # Assert that the previous character isn't a minus sign or a dot.
# Anchor the match to the start of a number.
[0-9]+ # Match a number.
# Anchor the match to the end of the number.
(?!.[0-9]) # Assert that no decimal part follows.
For signed/unsigned integers, use
r"[+-]?(?<!.)[0-9]+(?!.[0-9])"
The word boundaries
are crucial to make sure that the entire number is matched.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…