JavaScript regex for alphanumeric string with length of 3-5 chars December 19, 2023 by Tarik add {3,5} to your expression which means length between 3 to 5 /^([a-zA-Z0-9_-]){3,5}$/