Compare commits
No commits in common. "f3924b49615cf8068417d792b866ed14c7c22dc4" and "6f56d563d44c1eea3218a1ec90d4505b43654242" have entirely different histories.
f3924b4961
...
6f56d563d4
@ -2,11 +2,11 @@ import re
|
||||
import os
|
||||
|
||||
def find_hamlet_lines(file_path):
|
||||
with open(file_path, 'r', encoding='utf-8') as file:
|
||||
with open(file_path, 'r') as file:
|
||||
lines = file.readlines()
|
||||
|
||||
hamlet_lines = []
|
||||
pattern = re.compile(r'Hamlet')
|
||||
pattern = re.compile(r'\bHamlet\b')
|
||||
|
||||
for _, line in enumerate(lines, start=1):
|
||||
if re.search(pattern, line):
|
||||
|
@ -1,3 +1,3 @@
|
||||
Here comesHamlet
|
||||
Here comes Hamlet
|
||||
ABC
|
||||
Hamlet Hamlet again
|
||||
|
@ -1,19 +0,0 @@
|
||||
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)
|
@ -1,19 +0,0 @@
|
||||
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)
|
@ -1,14 +0,0 @@
|
||||
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