-5

Regular expression for "At least 8 Characters long include at least one letter and one numeric" using javascript. and string can have special characters .

Anupam Singh
  • 1,158
  • 13
  • 25
  • 1
    You didn't bother to search first, did you? It has been asked 3 years ago, exactly the same question: http://stackoverflow.com/questions/7684815/regex-for-alpanumeric-with-at-least-1-number-and-1-character – Terry Oct 18 '14 at 05:50
  • I did but the issue was special characters and length. I tried adding pattern but it doesnt work. and i m not good in regex. :(. – Anupam Singh Oct 18 '14 at 05:54
  • 1
    If you have tried anything, post your code here (even better: share it as a code snippet or a fiddle). That's what we are here to help — not to write code for you, but to check what could've gone wrong when you have a **specific** problem. – Terry Oct 18 '14 at 05:56
  • I tried ^(?=.*[0-9])(?=.*[a-zA-Z])([a-zA-Z0-9_@./#&+-]+)$. – Anupam Singh Oct 18 '14 at 06:45

1 Answers1

2

Edit, Updated

Note, Not entirely RegExp approach

Try

var str = "#1abcdef"
, len = str.length
, t = len >= 8 && str.match(/[a-z0-9]/gi).some(isFinite);
console.log(t)

RegExp (updated, added)

/.{8}/.test(str) && !!str.match(/[0-9]{1}[a-z]{1}|[a-z]{1}[0-9]{1}/i)
guest271314
  • 1
  • 15
  • 104
  • 177