ngPattern for validatin a String

25 Views Asked by At

We have a requirement for a string field validation as below:

  • It can contain alpha numeric characters and spaces are allowed too. But entire string can not be empty spaces alone.
  • Lenth is minimun 1 character and maximum legth is 7.
  • Case insensitive.

I tried the following Regex but it did not work.

/^(?!\s+$)[a-z\d\-_\s]{1,7}+$/i

Example Strings that should match: "QWE RTY", "qwe", "13 Z x", "sh qwe1" Example Strings that shoud not match:

  • "qw##@"(includes special characters)
  • " "(spaces)
  • "qwerty123"(more than 7 characters)
0

There are 0 best solutions below