16 lines
469 B
Python
16 lines
469 B
Python
import re
|
|
|
|
#Write a program to find lines containing date from 1900 to 1999 in format '19XX r.' no matter what on the left or right of the expression.
|
|
#Note that part ' r.' is obligatory.
|
|
#Do use regular expressions.
|
|
|
|
|
|
def data_reg(file_path):
|
|
with open(file_path, 'r', encoding='utf-8') as file:
|
|
for line in file:
|
|
if (re.search(".*19\d{2} r\..*", line)):
|
|
print(line.strip())
|
|
|
|
|
|
file_path = 'TaskD03\simple.in'
|
|
data_reg(file_path) |