Informatics1-2019/HW3
A MathWikiből
(Változatok közti eltérés)
(→Example) |
|||
(egy szerkesztő 5 közbeeső változata nincs mutatva) | |||
1. sor: | 1. sor: | ||
− | + | REGEX | |
− | You have to write | + | You have to write '''regular expression'''s matching specific patterns. |
Use this page: https://regex101.com/ and don't forget to set '''python''' flavor. | Use this page: https://regex101.com/ and don't forget to set '''python''' flavor. | ||
+ | |||
+ | = Leap years (2 points)= | ||
+ | |||
+ | Match the leap years in this specific way: a positive integer divisible by 4, except multiples of 100. And it shouldn't have a trailing zero on the beginning. | ||
+ | |||
+ | == Example== | ||
+ | |||
+ | These should be '''matched''': | ||
+ | |||
+ | * 4 | ||
+ | * 8 | ||
+ | * 12 | ||
+ | * 16 | ||
+ | * 160 | ||
+ | * 164 | ||
+ | * 1024 | ||
+ | * 2008 | ||
+ | * 2056 | ||
+ | * 20080 | ||
+ | * 1048576 | ||
+ | |||
+ | These should '''not match''': | ||
+ | * 1 | ||
+ | * 2 | ||
+ | * 3 | ||
+ | * 004 | ||
+ | * 5 | ||
+ | * 9 | ||
+ | * 11 | ||
+ | * 13 | ||
+ | * 21 | ||
+ | * 22 | ||
+ | * 23 | ||
+ | * 100 | ||
+ | * 0 | ||
+ | * 00 | ||
+ | * 0240 | ||
+ | * 2000 | ||
+ | * 1600 | ||
+ | * 200800 | ||
+ | |||
+ | = Vowel harmony (2 points)= | ||
The expression should find words containing only lowercase, latin characters. | The expression should find words containing only lowercase, latin characters. | ||
9. sor: | 51. sor: | ||
* It can start with any number of consonants, or a vowel. | * It can start with any number of consonants, or a vowel. | ||
* two vowels should not be next to each other. | * two vowels should not be next to each other. | ||
− | * it should match a whole word | + | * it should match a whole word |
== Hint == | == Hint == | ||
19. sor: | 61. sor: | ||
[^aeiou\s] | [^aeiou\s] | ||
+ | |||
+ | Also put '''\b''' in front and to the end, to make sure it matches a whole word. | ||
== Example== | == Example== | ||
− | These should be '' | + | These should be '''matched''': |
* mammal | * mammal | ||
+ | * mama | ||
+ | * uru | ||
* chlorophorm | * chlorophorm | ||
* oppo | * oppo | ||
+ | * imimi | ||
+ | * xerxes | ||
+ | * these | ||
− | + | These should '''not match''': | |
* mammut | * mammut | ||
+ | * url | ||
* choroid | * choroid | ||
* opponent | * opponent | ||
+ | * coop | ||
+ | * iii | ||
+ | |||
+ | =Handing in= | ||
+ | Write the two regular expressions in an email to '''info1hazi@gmail.com''' from your math account. | ||
+ | The subject should be: | ||
+ | A1_HW3_<username> | ||
== Deadline == | == Deadline == | ||
2019. October 13<sup>th</sup> 23:59 | 2019. October 13<sup>th</sup> 23:59 |
A lap jelenlegi, 2019. október 7., 15:12-kori változata
REGEX
You have to write regular expressions matching specific patterns. Use this page: https://regex101.com/ and don't forget to set python flavor.
Tartalomjegyzék |
Leap years (2 points)
Match the leap years in this specific way: a positive integer divisible by 4, except multiples of 100. And it shouldn't have a trailing zero on the beginning.
Example
These should be matched:
- 4
- 8
- 12
- 16
- 160
- 164
- 1024
- 2008
- 2056
- 20080
- 1048576
These should not match:
- 1
- 2
- 3
- 004
- 5
- 9
- 11
- 13
- 21
- 22
- 23
- 100
- 0
- 00
- 0240
- 2000
- 1600
- 200800
Vowel harmony (2 points)
The expression should find words containing only lowercase, latin characters.
- A word should be matched if it uses only the same vowel every time
- contains at least two vowels
- It can start with any number of consonants, or a vowel.
- two vowels should not be next to each other.
- it should match a whole word
Hint
For vowels you can use:
[aeiou]
And for consonants:
[^aeiou\s]
Also put \b in front and to the end, to make sure it matches a whole word.
Example
These should be matched:
- mammal
- mama
- uru
- chlorophorm
- oppo
- imimi
- xerxes
- these
These should not match:
- mammut
- url
- choroid
- opponent
- coop
- iii
Handing in
Write the two regular expressions in an email to info1hazi@gmail.com from your math account. The subject should be:
A1_HW3_<username>
Deadline
2019. October 13th 23:59