You can try this:
(?<=\b)\d+(?=[\s.,;])
Explanation:
(?<=\b)
Looks behind from the current position if it is a start of a word
\d+
If previous condition is found true then matches digits \d+
(?=[\s.,;])
If previous condition met, then look ahead to see if it ends with space or dot or comma or semicolon
demo
if I put word boundary after digits then 1999@ will also get selected. Shown in the demo
Sample Code:
import re
regex = r"(?<=\b)\d+(?=[\s.,;])"
test_str = "Hi I am sony. My age 23. This is my email id sony.1510@gmail.com . Hi I am Jessey. My age 20. This is my email id jessey.1996@gmail.com . Hi I am ronald.My age 17 My mail id is ronald.1999@gmail.com"
matches = re.finditer(regex, test_str, re.MULTILINE)
for match in matches:
print(match.group(0))
Run it here
UPDATE
\b ensures word boundary. I have put (?<=\b) at the beginning which is similar as \b. So the regex above is same as :
\b\d+(?=[\s.,;])
Here, The first \b makes sure that any matching will only start from a start of a word. Where start of a word means just after .(dot) ,(comma), ;(semicolon),space,tab, etc