2.4 KiB
id, title, challengeType, forumTopicId, dashedName
id | title | challengeType | forumTopicId | dashedName |
---|---|---|---|---|
587d7db9367417b2b2512ba5 | Specificare il numero superiore e inferiore di corrispondenze | 1 | 301367 | specify-upper-and-lower-number-of-matches |
--description--
Ricorda che puoi usare il segno più +
per cercare uno o più caratteri e l'asterisco *
per cercare zero o più caratteri. Questi sono utili, ma a volte si desidera riconoscere una certa gamma di pattern.
È possibile specificare il numero inferiore e superiore di pattern con gli specificatori di quantità. Gli specificatori di quantità sono utilizzati con le parentesi graffe ({
e }
). Metterai due numeri tra le parentesi graffe - per il numero inferiore e superiore di pattern.
Ad esempio, per riconoscere solo la lettera a
che appare tra 3
e 5
volte nella stringa ah
, la tua espressione regolare sarà /a{3,5}h/
.
let A4 = "aaaah";
let A2 = "aah";
let multipleA = /a{3,5}h/;
multipleA.test(A4);
multipleA.test(A2);
La prima chiamata a test
restituirà true
, mentre la seconda restituirà false
.
--instructions--
Cambiare l'espressione regolare ohRegex
in modo da riconoscere l'intera frase Oh no
solo quando ha da 3
a 6
lettere h
.
--hints--
La tua espressione regolare dovrebbe usare le parentesi graffe.
assert(ohRegex.source.match(/{.*?}/).length > 0);
La tua espressione regolare non dovrebbe riconoscere la stringa Ohh no
ohRegex.lastIndex = 0;
assert(!ohRegex.test('Ohh no'));
La tua espressione regolare dovrebbe riconoscere la stringa Ohhh no
assert('Ohhh no'.match(ohRegex)[0].length === 7);
La tua espressione regolare dovrebbe riconoscere la stringa Ohhhh no
assert('Ohhhh no'.match(ohRegex)[0].length === 8);
La tua espressione regolare dovrebbe riconoscere la stringa Ohhhhh no
assert('Ohhhhh no'.match(ohRegex)[0].length === 9);
La tua espressione regolare dovrebbe riconoscere la stringa Ohhhhhh no
assert('Ohhhhhh no'.match(ohRegex)[0].length === 10);
La tua espressione regolare non dovrebbe riconoscere la stringa Ohhhhhhh no
ohRegex.lastIndex = 0;
assert(!ohRegex.test('Ohhhhhhh no'));
--seed--
--seed-contents--
let ohStr = "Ohhh no";
let ohRegex = /change/; // Change this line
let result = ohRegex.test(ohStr);
--solutions--
let ohStr = "Ohhh no";
let ohRegex = /Oh{3,6} no/; // Change this line
let result = ohRegex.test(ohStr);