I have the following case:
Test (2.00001) Test (2.000) Test 2.1 Test (2,0001) Test 2,000 Test 2,1000 test 2
I try to use regex to find only the integers:
2.0002,0002
but not the other float numbers.
I tried different things:
re.search('(?<![0-9.])2(?![.,]?[1-9])(?=[.,]*[0]*)(?![1-9]),...)
but this returns true for:
2.000012.0002,0002,00012
What have I to do?
UPDATE
I have updated the question and it should also find an integer without any comma and point, too (2).
(?<!\d)(?<!\d[.,])\d{1,3}(?:[.,]\d{3})*(?![,.]?\d), see demo.test 2 2.002.00001, why do you want to match2.00? How can you formulate the pattern requirements regarding differentiation between valid and non-valid floats?(?<!\d)(?<!\d[.,])(?:\d{1,3}(?:([.,])\d{3})*|\d{4,})(?:(?!\1)[.,]0+)?(?![,.]?\d)? See regex101.com/r/qrG8hg/2(?<!\d)(?<!\d[.,])\d+(?:[.,]0+)?(?![,.]?\d)- see this demo.