0

I am new to Php starting working with regular expressions.

I am working on validating the Password input field data tried some other patterns like preg_match('/^[A-Z]*$/', $password) but this didn't work for password yet this regular expression is working on e-mail and UserName field.

So searched for the answer on google and got this pattern('@[A-Z]@') regular expression and it works fine but i don't understand what is the meaning of @ in this pattern

There are also other validation rules I only mentioned capital letter just to ask about my query...

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
  • 1
    `@` is used instead of a more common `/` as a delimiter char. – Wiktor Stribiżew Nov 03 '21 at 12:46
  • The main reason `^[A-Z]*$` "didn't work for password" for you, is that this pattern is anchored at the beginning and end - meaning, the value you are testing must _only_ consist of upper-case letters from start to finish. (Or be completely empty, since this is using the `*` modifier, it would allow for _zero_ characters out of the given class as well. – CBroe Nov 03 '21 at 13:11

0 Answers0