Решения по JS Flashcards
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).
/**
- ^
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.
*/
Обнаружение цифр - (/\d/)
function order(words){
return words.split(‘ ‘).sort(function(a, b){
return a.match(/\d/) - b.match(/\d/);
}).join(‘ ‘);
}