I\'m trying to verify that my string matches a pattern. That is, the full string can be written as that pattern.
However preg_match returns true, i
I super-love regex, but not for this task -- it is needless overhead because there is a single, direct, non-regex equivalent. https://www.php.net/manual/en/function.ctype-lower.php
Code: (Demo)
$tests = [
'Test',
'test',
'test1',
'1test',
'test!'
];
foreach ($tests as $test) {
echo "$test: " , (ctype_lower($test) ? 'true' : 'false') , "\n";
}
Output:
Test: false
test: true
test1: false
1test: false
test!: false
p.s. For the record, an empty string returns false. I'm not sure of your logical validation requirements for this test unit.