Решения по JS Flashcards

1
Q

Write a simple regex to validate a username. Allowed characters are:

lowercase letters,
numbers,
underscore
Length should be between 4 and 16 characters (both included).

A

/**
- ^ Start from the beginning of the string.
- [] Allow any character specified, including…
- a-z anything from a to z,
- 0-9 anything from 0 to 9,
- _ and underscore.
- {4,16} Accept 4 to 16 of allowed characters, both numbers included.
- $ End the string right after specified amount of allowed characters is given.
*/

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Обнаружение цифр - (/\d/)

A

function order(words){
return words.split(‘ ‘).sort(function(a, b){
return a.match(/\d/) - b.match(/\d/);
}).join(‘ ‘);
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly