What are the potential pitfalls of using regular expressions to check for uppercase characters in PHP?

Using regular expressions to check for uppercase characters in PHP may not be the most efficient or straightforward method. It can be prone to errors and may not accurately capture all uppercase characters in a given string. A more reliable approach would be to use PHP's built-in functions like ctype_upper() or simple iteration over the string to check for uppercase characters.

// Using ctype_upper() function to check for uppercase characters
$string = "Hello World";
$hasUppercase = false;

for($i = 0; $i < strlen($string); $i++) {
    if(ctype_upper($string[$i])) {
        $hasUppercase = true;
        break;
    }
}

if($hasUppercase) {
    echo "String contains uppercase characters.";
} else {
    echo "String does not contain uppercase characters.";
}