regex w domu

This commit is contained in:
B. Piatek 2020-01-23 12:38:31 +01:00
parent c9d22aa7a4
commit f4f83223e9
5 changed files with 35 additions and 0 deletions

8
regexp/Task301.py Normal file
View File

@ -0,0 +1,8 @@
import re
def letter_and_two_digits(text) -> bool:
if re.search("[A-Z]\d{2}", text):
return True
else:
return False

11
regexp/Task302.py Normal file
View File

@ -0,0 +1,11 @@
import re
def extract_minutes(date):
regex = "^([0-9]|1[0-9]|2[0-3]):([0-5][0-9])$"
out = re.search(regex, date)
if out is None:
return '<NONE>'
else:
return out.group(2)

5
regexp/Task303.py Normal file
View File

@ -0,0 +1,5 @@
import re
def divisable_by_four(string):
return re.search("^[048]$|^[0-9]*([13579][26]|[2468][048])$|^[1-9][0-9]*(00|04|08)$", string)

5
regexp/Task304.py Normal file
View File

@ -0,0 +1,5 @@
import re
def split_list(string):
return re.split(",\\s+|\\s+,\\s*|:", string)

6
regexp/Task328.py Normal file
View File

@ -0,0 +1,6 @@
import re
def is_hmmmm(string):
search = re.search("^hm{2,}(\.{3,}|)$", string)
return search