bez numerów linii

This commit is contained in:
wojtekgoralewski 2023-12-11 14:00:27 +01:00
parent 3908ac94e6
commit afd599225c
4 changed files with 4 additions and 12 deletions

View File

@ -1,12 +1,10 @@
import re
def hamlet_reg(file_path):
licznik = 0
with open(file_path, 'r', encoding='utf-8') as file:
for line in file:
licznik += 1
if (re.search("'.*Hamlet.*", line)):
print(f"{licznik}: {line.strip()}")
print(line.strip())
file_path = 'TaskD01\simple.in'
hamlet_reg(file_path)

View File

@ -1,12 +1,10 @@
import re
def pies_reg(file_path):
licznik = 0
with open(file_path, 'r', encoding='utf-8') as file:
for line in file:
licznik += 1
if (re.search("(^|\s)pies($|\s)", line, re.IGNORECASE)):
print(f"{licznik}: {line.strip()}")
print(line.strip())
file_path = 'TaskD02\simple.in'

View File

@ -6,12 +6,10 @@ import re
def data_reg(file_path):
licznik = 0
with open(file_path, 'r', encoding='utf-8') as file:
for line in file:
licznik += 1
if (re.search(".*19\d{2} r\..*", line)):
print(f"{licznik}: {line.strip()}")
print(line.strip())
file_path = 'TaskD03\simple.in'

View File

@ -6,13 +6,11 @@ import re
def liczby_reg(file_path):
licznik = 0
with open(file_path, 'r', encoding='utf-8') as file:
for line in file:
licznik += 1
number = (re.findall(r'\d+', line))
if number:
print(f"{licznik}: {' '.join(number)}")
print(' '.join(number))
file_path = 'TaskD04\simple.in'