Skip to content

String Character Checks ​

The generated Str class exposes Laravel's string helpers and the following checks. Each method accepts a string and returns true only if it is nonempty and every character matches the condition.

MethodCharacters allowedExample returning trueExample returning false
isAlphanumericLetters and digits'abc123''abc 123'
isAlphaLetters'abc''abc1'
isControlControl characters"\n\r""a\n"
isDigitDecimal digits'123''-123'
isGraphVisible, printable characters'abc!23''abc 23'
isLowerLowercase letters'abc''Abc'
isPrintPrintable characters, including spaces'abc 23'"abc\n23"
isPunctPrintable characters other than spaces, letters, or digits'!@#''a!'
isSpaceWhitespace" \t"'a '
isUpperUppercase letters'ABC''ABc'
isHexHexadecimal digits (0–9, A–F, a–f)'1a2B''1g2B'
php
use App\Helpers\Str;

Str::isDigit('123'); // true
Str::isDigit('');    // false

These are PHP ctype checks. They use the process's character type locale and do not validate Unicode character categories in UTF-8 strings.

Released under the MIT License.