how to find all "1401/07/29 19:00:00" pattern in a text with regex in python

Question:

i have a text that contain "1401/07/29 19:00:00" pattern.
how find all top pattern in text with re.findall method in python

Answers:

if string = "1401/07/29 19:00:00"

re.findall(r'd{4}/d{2}/d{2} d{2}:d{2}:d{2}', string)

if string = '1401/07/29 19:00:00'

string = '1401/07/29 19:00:00'

#variant 1
print(re.findall(r'd{4}\/d{2}\/d{2} d{2}:d{2}:d{2}', string)) 
#output: ['1401\/07\/29 19:00:00']

#variant 2
print(re.findall(r'd{4}/d{2}/d{2} d{2}:d{2}:d{2}', string.replace("\",'' ))) 
#output: ['1401/07/29 19:00:00']
Answered By: Dmitriy Neledva
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.