B
B
Banan442020-05-16 13:01:29
JavaScript
Banan44, 2020-05-16 13:01:29

Regular expression for js password validation?

let string = 'password123'
let pattern = /что-то/
console.log(pattern.test(string)) // true

Password from 3 to 20 characters
Must contain Latin + numbers (minimum 1 digit)
What template should I write?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Sarvarov, 2020-05-16
@Banan44

/^(?=.*\d)\w{3,20}$/m
https://regex101.com/r/H47hPN/3

S
SOTVM, 2020-05-16
@sotvm

first match valid characters and their number / ^[a-zA-Z0-9]{3,20}$ /
after match more than one digit (but not all 20) / [0-9]{1,19} /
if these two conditions are met, then :)
if not :(

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question