Skip to content

Commit 399df24

Browse files
committed
translated chapter 12 exercises 1 and 2, both tasks and solutions
1 parent 1909909 commit 399df24

File tree

4 files changed

+21
-21
lines changed

4 files changed

+21
-21
lines changed
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
The empty string is the only match: it starts and immediately finishes.
2+
L'unica corrispondenza si ha con la stringa vuota: inizia e poi finisce immediatamente.
33

4-
The task once again demonstrates that anchors are not characters, but tests.
4+
Questo task dimostra ancora che gli ancoraggi non rappresentano caratteri, bensì test.
55

6-
The string is empty `""`. The engine first matches the `pattern:^` (input start), yes it's there, and then immediately the end `pattern:$`, it's here too. So there's a match.
6+
La stringa è vuota `""`. Il motore prima fa cerca corrispondenze per `pattern:^` (inizio input), ed è presente, e subito dopo cerca la fine `pattern:$`, e c'è anch'essa. Quindi c'è corrispondenza.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Regexp ^$
22

3-
Which string matches the pattern `pattern:^$`?
3+
Quale stringa corrisponde al pattern `pattern:^$`?
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
A two-digit hex number is `pattern:[0-9a-f]{2}` (assuming the `pattern:i` flag is enabled).
1+
Una coppia di cifre esadecimali è `pattern:[0-9a-f]{2}` (assumendo che la flag `pattern:i` sia abilitata).
22

3-
We need that number `NN`, and then `:NN` repeated 5 times (more numbers);
3+
Abbiamo bisogno di quella coppia `NN`, e dopo `:NN` ripetuto per 5 volte (altre coppie);
44

5-
The regexp is: `pattern:[0-9a-f]{2}(:[0-9a-f]{2}){5}`
5+
La regexp è: `pattern:[0-9a-f]{2}(:[0-9a-f]{2}){5}`
66

7-
Now let's show that the match should capture all the text: start at the beginning and end at the end. That's done by wrapping the pattern in `pattern:^...$`.
7+
Ora dimostriamo che la corrispondenza catturi tutto il testo: che inizi con l'indirizzo MAC e finisca al suo termine. Otteniamo questo risultato circondando il pattern da `pattern:^...$`.
88

9-
Finally:
9+
Infine:
1010

1111
```js run
1212
let reg = /^[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}$/i;
1313

1414
alert( reg.test('01:32:54:67:89:AB') ); // true
1515

16-
alert( reg.test('0132546789AB') ); // false (no colons)
16+
alert( reg.test('0132546789AB') ); // false (non ci sono i due punti)
1717

18-
alert( reg.test('01:32:54:67:89') ); // false (5 numbers, need 6)
18+
alert( reg.test('01:32:54:67:89') ); // false (5 numeri, devono essere 6)
1919

20-
alert( reg.test('01:32:54:67:89:ZZ') ) // false (ZZ in the end)
20+
alert( reg.test('01:32:54:67:89:ZZ') ) // false (ZZ alla fine)
2121
```
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
# Check MAC-address
1+
# Controllo MAC-address
22

3-
[MAC-address](https://en.wikipedia.org/wiki/MAC_address) of a network interface consists of 6 two-digit hex numbers separated by a colon.
3+
Il [MAC-address](https://it.wikipedia.org/wiki/Indirizzo_MAC) di un'interfaccia di rete è composto da 6 coppie di cifre esadecimali separati dai due punti.
44

5-
For instance: `subject:'01:32:54:67:89:AB'`.
5+
Per esempio: `subject:'01:32:54:67:89:AB'`.
66

7-
Write a regexp that checks whether a string is MAC-address.
7+
Scrivi una regexp che controlli se una stringa sia un MAC-address.
88

9-
Usage:
9+
Uso:
1010
```js
11-
let reg = /your regexp/;
11+
let reg = /la tua regexp/;
1212

1313
alert( reg.test('01:32:54:67:89:AB') ); // true
1414

15-
alert( reg.test('0132546789AB') ); // false (no colons)
15+
alert( reg.test('0132546789AB') ); // false (non ci sono i due punti)
1616

17-
alert( reg.test('01:32:54:67:89') ); // false (5 numbers, must be 6)
17+
alert( reg.test('01:32:54:67:89') ); // false (5 coppie, devono essere 6)
1818

19-
alert( reg.test('01:32:54:67:89:ZZ') ) // false (ZZ ad the end)
19+
alert( reg.test('01:32:54:67:89:ZZ') ) // false (ZZ alla fine)
2020
```

0 commit comments

Comments
 (0)