diff options
| -rw-r--r-- | cs-cz/python3.html.markdown | 27 | ||||
| -rw-r--r-- | it-it/pcre-it.html.markdown | 13 | ||||
| -rw-r--r-- | pcre.html.markdown | 25 | ||||
| -rw-r--r-- | zh-tw/pcre-tw.html.markdown | 9 | 
4 files changed, 47 insertions, 27 deletions
| diff --git a/cs-cz/python3.html.markdown b/cs-cz/python3.html.markdown index 2cbf52e6..bd3690a8 100644 --- a/cs-cz/python3.html.markdown +++ b/cs-cz/python3.html.markdown @@ -137,12 +137,14 @@ None  # => None  "něco" is None  # => False  None is None    # => True -# None, 0, a prázdný řetězec/seznam/slovník se vyhodnotí jako False +# None, 0, a prázdný řetězec/seznam/N-tice/slovník/množina se vyhodnotí jako False  # Vše ostatní se vyhodnotí jako True -bool(0)   # => False -bool("")  # => False -bool([])  # => False -bool({})  # => False +bool(0)        # => False +bool("")       # => False +bool([])       # => False +bool(tuple())  # => False +bool({})       # => False +bool(set())    # => False  #################################################### @@ -602,18 +604,21 @@ dir(math)  # Generátory jsou funkce, které místo return obsahují yield  def nasobicka_2(sekvence):      for i in sekvence: +        print("Zpracovávám číslo {}".format(i))          yield 2 * i  # Generátor generuje hodnoty postupně, jak jsou potřeba. Místo toho, aby vrátil  # celou sekvenci s prvky vynásobenými dvěma, provádí jeden výpočet v každé iteraci. -# To znamená, že čísla větší než 15 se v metodě nasobicka_2 vůbec nezpracují. +for nasobek in nasobicka_2([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]): +    # Vypíše postupně: "Zpracovávám číslo 1",  ...,  "Zpracovávám číslo 5" +    if nasobek >= 10: +        break  # Funkce range() je také generátor - vytváření seznamu 900000000 prvků by zabralo  # hodně času i paměti, proto se místo toho čísla generují postupně. - -for i in nasobicka_2(range(900000000)): -    print(i)  # Vypíše čísla 0, 2, 4, 6, 8, ... 30 -    if i >= 30: +for nasobek in nasobicka_2(range(900000000)): +    # Vypíše postupně: "Zpracovávám číslo 1",  ...,  "Zpracovávám číslo 5" +    if nasobek >= 10:          break @@ -633,7 +638,7 @@ def nekolikrat(puvodni_funkce):  def pozdrav(jmeno):      print("Měj se {}!".format(jmeno)) -pozdrav("Pepo")  # Vypíše 3x: Měj se Pepo! +pozdrav("Pepo")  # Vypíše 3x: "Měj se Pepo!"  ```  ## Co dál? diff --git a/it-it/pcre-it.html.markdown b/it-it/pcre-it.html.markdown index 68233858..704392ef 100644 --- a/it-it/pcre-it.html.markdown +++ b/it-it/pcre-it.html.markdown @@ -11,7 +11,7 @@ lang: it-it  Un'espressione regolare (regex o regexp in breve) è una speciale stringa  utilizzata per definire un pattern, ad esempio per cercare una sequenza di  caratteri; ad esempio, `/^[a-z]+:/` può essere usato per estrarre `http:` -dall'URL `http://github.com/`.   +dall'URL `http://github.com/`.  PCRE (Perl Compatible Regular Expressions) è una libreria per i regex in C.  La sintassi utilizzata per le espressioni è molto simile a quella di Perl, da @@ -19,7 +19,9 @@ cui il nome. Si tratta di una delle sintassi più diffuse per la scrittura di  regex.  Esistono due tipi di metacaratteri (caratteri con una funzione speciale): +  * Caratteri riconosciuti ovunque tranne che nelle parentesi quadre +  ```    \      carattere di escape    ^      cerca all'inizio della stringa (o della riga, in modalità multiline) @@ -36,16 +38,17 @@ Esistono due tipi di metacaratteri (caratteri con una funzione speciale):  ```  * Caratteri riconosciuti nelle parentesi quadre +  ```    \      carattere di escape    ^      nega la classe se è il primo carattere    -      indica una serie di caratteri    [      classe caratteri POSIX (se seguita dalla sintassi POSIX)    ]      termina la classe caratteri -   -```   +``` + +PCRE fornisce inoltre delle classi di caratteri predefinite: -PCRE fornisce inoltre delle classi di caratteri predefinite:   ```    \d     cifra decimale    \D     NON cifra decimale @@ -62,9 +65,11 @@ PCRE fornisce inoltre delle classi di caratteri predefinite:  ## Esempi  Utilizzeremo la seguente stringa per i nostri test: +  ```  66.249.64.13 - - [18/Sep/2004:11:07:48 +1000] "GET /robots.txt HTTP/1.0" 200 468 "-" "Googlebot/2.1"  ``` +  Si tratta di una riga di log del web server Apache.  | Regex | Risultato          | Commento | diff --git a/pcre.html.markdown b/pcre.html.markdown index 3e877a35..9e091721 100644 --- a/pcre.html.markdown +++ b/pcre.html.markdown @@ -3,16 +3,18 @@ language: PCRE  filename: pcre.txt  contributors:      - ["Sachin Divekar", "http://github.com/ssd532"] -     +  --- -A regular expression (regex or regexp for short) is a special text string for describing a search pattern. e.g. to extract domain name from a string we can say `/^[a-z]+:/` and it will match `http:` from `http://github.com/`.   +A regular expression (regex or regexp for short) is a special text string for describing a search pattern. e.g. to extract domain name from a string we can say `/^[a-z]+:/` and it will match `http:` from `http://github.com/`.  PCRE (Perl Compatible Regular Expressions) is a C library implementing regex. It was written in 1997 when Perl was the de-facto choice for complex text processing tasks. The syntax for patterns used in PCRE closely resembles Perl. PCRE syntax is being used in many big projects including PHP, Apache, R to name a few.  There are two different sets of metacharacters: +  * Those that are recognized anywhere in the pattern except within square brackets +  ```    \      general escape character with several uses    ^      assert start of string (or line, in multiline mode) @@ -32,18 +34,19 @@ There are two different sets of metacharacters:  ```  * Those that are recognized within square brackets. Outside square brackets. They are also called as character classes. -  +  ``` -  +    \      general escape character    ^      negate the class, but only if the first character    -      indicates character range    [      POSIX character class (only if followed by POSIX syntax)    ]      terminates the character class -   -```   -PCRE provides some generic character types, also called as character classes.  +``` + +PCRE provides some generic character types, also called as character classes. +  ```    \d     any decimal digit    \D     any character that is not a decimal digit @@ -59,7 +62,13 @@ PCRE provides some generic character types, also called as character classes.  ## Examples -We will test our examples on following string `66.249.64.13 - - [18/Sep/2004:11:07:48 +1000] "GET /robots.txt HTTP/1.0" 200 468 "-" "Googlebot/2.1"`. It is a standard Apache access log. +We will test our examples on the following string: + +``` +66.249.64.13 - - [18/Sep/2004:11:07:48 +1000] "GET /robots.txt HTTP/1.0" 200 468 "-" "Googlebot/2.1" +``` + + It is a standard Apache access log.  | Regex | Result          | Comment |  | :---- | :-------------- | :------ | diff --git a/zh-tw/pcre-tw.html.markdown b/zh-tw/pcre-tw.html.markdown index c9cdc537..5f681d46 100644 --- a/zh-tw/pcre-tw.html.markdown +++ b/zh-tw/pcre-tw.html.markdown @@ -13,7 +13,9 @@ lang: zh-tw  相容Perl正規表達式(Perl Compatible Regular Expressions, PCRE)是一個實作正規表達式的C語言函式庫。此函式庫在1997年被開發出來,在當時面對複雜字串處理時大多會選擇使用Perl。也因為如此,PCRE大多的正規表達式語法都很酷似Perl。PCRE語法被廣泛運用在許多大專案中,包括PHP、Apache、R等。  PCRE中的超字元(metacharacter)主要可以分為以下兩類: +  * 在中括號外會被辨識的字元 +  ```    \      通用跳脫字元    ^      字串開頭 或 行首 @@ -33,18 +35,17 @@ PCRE中的超字元(metacharacter)主要可以分為以下兩類:  ```  * 在中括號內會被辨識的超字元,在中括號外會被視為字元集合使用 -  +  ``` -     \      通用跳脫字元    ^      非字元集合的字,但只會抓到第一個符合的字元    -      字元範圍    [      POSIX字元集合(若後面接POSIX格式)    ]      字元集合定義結束 -   -```   +```  PCRE提供了一些通用的字元類型,可被當作字元集合使用 +  ```    \d     任何數字字元    \D     任何非數字字元 | 
