Regex - validation for string match the following characters

0 votes
200 views
added Nov 8, 2018 in Regex by LC Marshal Captain (25,790 points)
//^([a-z0-9]{5,})$
//Use regex.test() for boolean result:

/^([a-z0-9]{5,})$/.test('hello1');   // false
/^([a-z0-9]{5,})$/.test('hello12');   // true
/^([a-z0-9]{5,})$/.test('hello123');   // true

//you could remove the () from regex since there's no need to capture it.

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...