fix automatic code translation
This commit is contained in:
parent
e7c1ffea2f
commit
3db5ee77c8
@ -95,7 +95,7 @@ To study, it is better to use interactive python interpreter, preferably ipython
|
|||||||
```
|
```
|
||||||
import re
|
import re
|
||||||
|
|
||||||
text = 'Ala has a cat and hammock, and 150 bananas.'
|
text = 'Ala ma kota i hamak, oraz 150 bananów.'
|
||||||
|
|
||||||
re.search('ma',text)
|
re.search('ma',text)
|
||||||
re.match('ma',text)
|
re.match('ma',text)
|
||||||
@ -117,39 +117,39 @@ re.search('\d{3}',text)
|
|||||||
|
|
||||||
re.search('\d+',text)
|
re.search('\d+',text)
|
||||||
|
|
||||||
re.search('\d+ bananas',text)
|
re.search('\d+ bananów',text)
|
||||||
re.search('\d* bananas', 'Ala has a lot of bananas')
|
re.search('\d* bananów','Ala ma dużo bananów')
|
||||||
re.search('\d* bananas',text)
|
re.search('\d* bananów',text)
|
||||||
re.search('ma \d? bananas','Ala has 5 bananas')
|
re.search('ma \d? bananów','Ala ma 5 bananów')
|
||||||
re.search('ma ?d? bananas','Ala has bananas')
|
re.search('ma ?\d? bananów','Ala ma bananów')
|
||||||
re.search('ma(\d)? bananas', 'Ala has bananas')
|
re.search('ma( \d)? bananów','Ala ma bananów')
|
||||||
|
|
||||||
re.search('\d+ bananas', 'Ala has 10 bananas or 20 bananas')
|
re.search('\d+ bananów','Ala ma 10 bananów albo 20 bananów')
|
||||||
re.search('\d+ bananas$', 'Ala has 10 bananas or 20 bananas')
|
re.search('\d+ bananów$','Ala ma 10 bananów albo 20 bananów')
|
||||||
|
|
||||||
text = 'Ala has a cat and hammock, and 150 bananas.'
|
text = 'Ala ma kota i hamak, oraz 150 bananów.'
|
||||||
|
|
||||||
re.search('\d+ bananas',text)
|
re.search('\d+ bananów',text)
|
||||||
|
|
||||||
re.search('\d+\sbananów',text)
|
re.search('\d+\sbananów',text)
|
||||||
|
|
||||||
re.search('kota . hamak',text)
|
re.search('kota . hamak',text)
|
||||||
|
|
||||||
re.search('cat . hammock','Ala has a cat with a hammock')
|
re.search('kota . hamak','Ala ma kota z hamakiem')
|
||||||
|
|
||||||
re.search('cat .* hammock','Ala has a cat or hammock')
|
re.search('kota .* hamak','Ala ma kota lub hamak')
|
||||||
|
|
||||||
re.search('\.',text)
|
re.search('\.',text)
|
||||||
|
|
||||||
re.search('cat|psa','Ala has a cat or hammock')
|
re.search('kota|psa','Ala ma kota lub hamak')
|
||||||
|
|
||||||
re.findall('cat|psa','Ala has a cat or a dog')
|
re.findall('kota|psa','Ala ma kota lub psa')
|
||||||
|
|
||||||
re.search('cat (i|or) dog','Ala has a cat or dog')
|
re.search('kota (i|lub) psa','Ala ma kota lub psa')
|
||||||
|
|
||||||
re.search('mam (cat).*(cat|psa)','I have a cat. Ala has a dog.').group(0)
|
re.search('mam (kota).*(kota|psa)','Ja mam kota. Ala ma psa.').group(0)
|
||||||
|
|
||||||
re.search('mam (cat).*(cat|psa)','I have a cat. Ala has a dog.').group(1)
|
re.search('mam (kota).*(kota|psa)','Ja mam kota. Ala ma psa.').group(1)
|
||||||
|
|
||||||
re.search('mam (cat).*(cat|psa)','I have a cat. Ala has a dog.').group(2)
|
re.search('mam (kota).*(kota|psa)','Ja mam kota. Ala ma psa.').group(2)
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user