In the CRM program, I try to customize the field so that only capital letters in English are entered.
Did this: [AZ] - but when you enter a lowercase also rolls
[AZ]{3,40} - Applies to first sentence only.

How to make it possible to enter data only this way, for example: VASILIY ANTONOV ?

  • 3
    It can mark the beginning of the line ^ and the end of the line $ that the expression checks not an arbitrary part of it, but the whole - Mike
  • 2
    Perhaps the following: ^ [AZ] * & - Crystal
  • one
    @bakusite except letters - spaces or special characters can be? - splash58
  • four
    so spaces should also be added - ^[AZ ]*$ - splash58
  • 3
    and if you want at least one letter to be, change the star to plus - splash58

2 answers 2

It is likely that this ORM uses a regular expression match with the IGNORE_CASE flag necessarily turned IGNORE_CASE .
You can try to turn this flag off if ORM uses the PCRE engine:

 ^(?-i)[AZ ]+$ 

The regular expression reads like this: disable IGNORE_CASE , [AZ] or space at least once.

    If you plan to check a non-empty field with words written in capital letters and separated by a single space , then such a regular expression will do:

     (^[AZ]+(?: [AZ]+)*$) 

    If you need to enable an empty field, then you can do this:

     (^[AZ]+(?: [AZ]+)*|$)