1

I need a regex pattern that will only match if the string has only lower case alphabets and digits, while at least one lower case alphabet and at least one digit has to exist. No other characters like upper case, space, special characters are allowed.

I currently have ^(?=.*[a-z])(?=.*[0-9]).+$ which I got from: RegEx to make sure that the string contains at least one lower case char, upper case char, digit and symbol

However, this seems to still accept strings that have other characters. How do I achieve it?

Community
  • 1
  • 1
whiteSkar
  • 1,614
  • 2
  • 17
  • 30

1 Answers1

2
^(?=.*[a-z])(?=.*[0-9])[a-z0-9]+$

                     ^^^^^^^^

You need to change the string to be accepted.

vks
  • 67,027
  • 10
  • 91
  • 124