hotmeteor/regex to zestaw gotowych metod pomocniczych regex do użycia w aplikacji Laravel:
🧠 Morning!
— Adam Campbell (@hotmeteor) August 9, 2021
If you're like me and are both a Laravel user and despise fiddling with common regex patterns, then I have something for you.
Introducing Regex, a set of ready-made regex helper methods for use in your app.
Check it out, and send ideas! https://t.co/PbNDoKQxXG
Ten pakiet zawiera popularne wzorce wyrażeń regularnych, które można dopasować i zastąpić wartościami. Pakiet obsługuje wielkość liter, znaki Unicode i obsługuje wszystkie języki.
Oto kilka przykładów z readme pakietu:
// Match
Regex::isAlpha($subject, $allowWhitespace = false);
Regex::isAlphanumeric($subject, $allowWhitespace = false);
Regex::isAlphadash($subject, $allowWhitespace = false);
Regex::isDigits($subject, $allowWhitespace = false);
Regex::isNumeric($subject);
// Replace
Regex::alpha($subject, $replace = '');
Regex::alphanumeric($subject, $replace = '');
Regex::alphadash($subject, $replace = '');
Regex::digits($subject, $replace = '');
Regex::numeric($subject, $replace = '');
Masz również dostęp do podstawowych metod match
i replace
dla wzorców niestandardowych:
// Replace interface
public static function replace($subject, $pattern, $replacement = '');
// Match interface
public static function match($subject, $pattern, bool $allowWhitespace = false): bool;
Możesz dowiedzieć się więcej o tym pakiecie, uzyskać pełne instrukcje instalacji i wyświetlić kod źródłowyna GitHubie.