0

If there are no lowercase letters in a string using PHP "preg_match", "No lowercase letters!" I want to print the warning.

Normally, there is no letter " İ " among the allowed characters. But the warning I want is not displayed.


Desired Result:

I want a warning displayed when there are different characters, except for those allowed.


Allowable lowercase letter list;

[a-z]

a b c d e f g h i j k l m n o p q r s t u v w x y z

Extra Small Letters

ığüşöç


My Faulty Code:

    <?php
        $string = "THIS İS A TEST";
        
        if (!preg_match("/[a-zığüşöç]/",$string)){
            echo 'No lowercase letters!';
        }

        // Result: empty

    ?>

Reply

if (!preg_match("/[a-zığüşöç]+$/",$string)){
    echo 'No lowercase letters!';
}
Jack Nal
  • 53
  • 6
  • I don't understand your problem. `$string` doesn't contain any of the letters in the prohibited list, so your code correctly reports it. If I add a prohibited letter it doesn't. Perhpas you just need to remove the `!` operator. –  Sep 26 '20 at 00:50
  • @CatchAsCatchCan It will give a warning since there is no lower case letter. – Jack Nal Sep 26 '20 at 00:54
  • @CatchAsCatchCan allowed characters are available, but all are large. It should only give the warning when there is no lower case letter. – Jack Nal Sep 26 '20 at 00:55
  • preg_match("/[a-zığüşöç]+$/",$string) – Jack Nal Sep 26 '20 at 01:15

0 Answers0