(Python) (regular expression) regular expression scoping unexpected output, and how can I change

Viewed 18

I'm working on Python regular expression, but scoping the unexpected output
I did see the link re.findall behaves weird but still not sure how to fix it, thanks.

('2022-11-15', '-', '-')

instead of the nomarl date

('2022-11-15')

import re

#ps the number is always after "," for input

text = "Original string: 2022-11-15, 100;"

print ( "Date", ( re.findall (r'(\d+(/|-|.){1}\d+(/|-|.){1}\d{2,4})',text)))

print ( "number", ( re.findall (r',\.?([ \d.]+)',text)))

(pic) code and output

0 Answers
Related