Odpowiedzi regexp
This commit is contained in:
parent
b74810884c
commit
a4430c57ba
9
regexp/Task301.py
Normal file
9
regexp/Task301.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import re
|
||||||
|
def letter_and_two_digits(napis):
|
||||||
|
if re.search(r'[A-Z]\d{2}', napis):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
14
regexp/Task302.py
Normal file
14
regexp/Task302.py
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def extract_minutes(string):
|
||||||
|
pattern = r'^([\d]|1[\d]|2[0-3]):([0-5][\d])$'
|
||||||
|
out = re.search(pattern, string)
|
||||||
|
|
||||||
|
if out is None:
|
||||||
|
return '<NONE>'
|
||||||
|
else:
|
||||||
|
return out.group(2)
|
6
regexp/Task303.py
Normal file
6
regexp/Task303.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def divisable_by_four(string):
|
||||||
|
wyrazenie = '^[048]$|^[0-9]*([13579][26]|[2468][048])$|^[1-9][0-9]*(00|04|08)$'
|
||||||
|
return re.search(wyrazenie, string)
|
Loading…
Reference in New Issue
Block a user