Compare commits
3 Commits
6f56d563d4
...
f3924b4961
Author | SHA1 | Date | |
---|---|---|---|
|
f3924b4961 | ||
|
c40716abe8 | ||
|
e1be7d9d73 |
@ -2,11 +2,11 @@ import re
|
||||
import os
|
||||
|
||||
def find_hamlet_lines(file_path):
|
||||
with open(file_path, 'r') as file:
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
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):
|
||||
|
@ -1,3 +1,3 @@
|
||||
Here comes Hamlet
|
||||
Here comesHamlet
|
||||
ABC
|
||||
Hamlet Hamlet again
|
||||
|
19
TaskD02/run.py
Normal file
19
TaskD02/run.py
Normal file
@ -0,0 +1,19 @@
|
||||
import re
|
||||
import os
|
||||
|
||||
def find_pies_lines(file_path):
|
||||
with open(file_path, 'r', encoding='utf-8') 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)
|
19
TaskD03/run.py
Normal file
19
TaskD03/run.py
Normal file
@ -0,0 +1,19 @@
|
||||
import re
|
||||
import os
|
||||
|
||||
def find_date_lines(file_path):
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
lines = file.readlines()
|
||||
|
||||
pies_lines = []
|
||||
pattern = re.compile(r'19[0-9][0-9] r\.')
|
||||
|
||||
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_date_lines(path)
|
||||
print(lines)
|
14
TaskD04/run.py
Normal file
14
TaskD04/run.py
Normal file
@ -0,0 +1,14 @@
|
||||
import re
|
||||
import os
|
||||
|
||||
def find_digits(file_path):
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
txt = file.read()
|
||||
pattern = re.compile(r'\d+')
|
||||
return pattern.findall(txt)
|
||||
|
||||
|
||||
|
||||
path = os.path.join(os.path.dirname(__file__), 'simple.in')
|
||||
matches = find_digits(path)
|
||||
print(matches)
|
Loading…
Reference in New Issue
Block a user