Informatics1-2019/HW3
A MathWikiből
(Változatok közti eltérés)
a |
|||
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. | ||
+ | |||
+ | == Example== | ||
+ | |||
+ | These should be '''match'''ed: | ||
+ | |||
+ | * 4 | ||
+ | * 8 | ||
+ | * 12 | ||
+ | * 16 | ||
+ | * 160 | ||
+ | * 164 | ||
+ | * 1024 | ||
+ | * 2008 | ||
+ | * 2056 | ||
+ | * 20080 | ||
+ | * 1048576 | ||
+ | |||
+ | These should '''not match''': | ||
+ | * 1 | ||
+ | * 2 | ||
+ | * 3 | ||
+ | * 5 | ||
+ | * 9 | ||
+ | * 11 | ||
+ | * 13 | ||
+ | * 21 | ||
+ | * 22 | ||
+ | * 23 | ||
+ | * 100 | ||
+ | * 0 | ||
+ | * 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. | ||
19. sor: | 58. sor: | ||
[^aeiou\s] | [^aeiou\s] | ||
+ | |||
+ | Also put '''\b''' in front and to the end, to make sure it matches a whole word. | ||
== Example== | == Example== | ||
25. sor: | 66. sor: | ||
* mammal | * mammal | ||
+ | * mama | ||
+ | * uru | ||
* chlorophorm | * chlorophorm | ||
* oppo | * oppo | ||
* imimi | * imimi | ||
* xerxes | * xerxes | ||
+ | * these | ||
These should '''not match''': | These should '''not match''': | ||
* mammut | * mammut | ||
+ | * url | ||
* choroid | * choroid | ||
* opponent | * opponent | ||
+ | * coop | ||
* iii | * 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 2019. október 7., 14:58-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.
Example
These should be matched:
- 4
- 8
- 12
- 16
- 160
- 164
- 1024
- 2008
- 2056
- 20080
- 1048576
These should not match:
- 1
- 2
- 3
- 5
- 9
- 11
- 13
- 21
- 22
- 23
- 100
- 0
- 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