This commit is contained in:
Pawel Felcyn 2023-12-11 14:16:28 +01:00
parent 6f56d563d4
commit e1be7d9d73
3 changed files with 21 additions and 2 deletions

View File

@ -6,7 +6,7 @@ def find_hamlet_lines(file_path):
lines = file.readlines()
hamlet_lines = []
pattern = re.compile(r'\bHamlet\b')
pattern = re.compile(r'Hamlet')
for _, line in enumerate(lines, start=1):
if re.search(pattern, line):

View File

@ -1,3 +1,3 @@
Here comes Hamlet
Here comesHamlet
ABC
Hamlet Hamlet again

19
TaskD02/run.py Normal file
View File

@ -0,0 +1,19 @@
import re
import os
def find_pies_lines(file_path):
with open(file_path, 'r') as file:
lines = file.readlines()
pies_lines = []
pattern = re.compile(r'\b[pP][iI][eE][sS]\b')
for _, line in enumerate(lines, start=1):
if re.search(pattern, line):
pies_lines.append(line)
return pies_lines
path = os.path.join(os.path.dirname(__file__), 'simple.in')
lines = find_pies_lines(path)
print(lines)